3475

QG_office
tough_boy
kitsch_l
Harry666
earl0701

mmmmm
Hououin_Jaeger
Susanna
connEction
7suki
NUC-CYJ
wqzgg
yx0007
yxc的小迷妹

StkOvflow
Marco_AF
18315752891

#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int main()
{
string str;
int n;
cin >> n >> str;
int cnt = 0, ans = 0;
for(int i = 0; i < n; i++)
{
if(str[i] == 'x')
{
cnt++;
if(cnt == 3)
{
cnt--;
ans++;
}
}
else cnt = 0;
}
cout << ans;
return 0;
}


#include<iostream>

using namespace std;
const int N = 1e5+10;
int a[N], b[N];

int main()
{
int n, m, x;
cin >> n >> m >> x;
for(int i = 0; i < n; i++) scanf("%d", &a[i]);
for(int i = 0; i < m; i++) scanf("%d", &b[i]);

int i = 0, j = m-1;
while(a[i] + b[j] != x)
{
if(a[i] + b[j] > x) j--;
else i++;
}
cout << i << " " << j;
return 0;
}


#include<iostream>

using namespace std;
const int N = 1e5+10;
int a[N],idx[N];

int main()
{
int n;
cin >> n;
for(int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}

int res = 0;
for(int i = 0, j = 0; i < n; i++)
{
idx[a[i]]++;
while(idx[a[i]] > 1)
{
idx[a[j]]--;
j++;
}
res = max(res, i-j+1);
}
cout << res;
return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;
const int N = 1010;
int n, k;

struct Stu
{
int id, ok;
}s[N];

bool check(int x)
{
if(x % k == 0 || x % 10 == k) return true;
return false;
}

int main()
{
cin >> n >> k;
int res;
int cnt = n;
for(int i = 1; i <= n; i++)
{
s[i] = {i, 1};
}

int num = 1;
while(cnt != 1)
{
for(int i = 1; i <= n; i++)
{
if(s[i].ok)
{
if(check(num))
{
s[i].ok = 0; // 删除该元素
//printf("id:%d num:%d\n", s[i].id, num);
cnt--;
if(cnt == 1) break;
}
}
else continue; // 当前元素已经被删除了直接跳到下一重循环
num++;
//printf("cnt:%d num:%d\n", cnt, num)

}
}
for(int i = 1; i <= n; i++)
{
if(s[i].ok) cout << s[i].id;
}
return 0;
}


#include<iostream>

using namespace std;
const int N = 1e5+10;
int nums[N];

int main()
{
int n, q;
cin >> n >>q;

for(int i = 0; i < n; i++)
{
cin >> nums[i];
}

while(q--)
{
int k;
cin >> k;
int l = 0, r = n-1;
while(l < r)
{
int mid = (l+r)>>1;
if(nums[mid] >= k) r = mid;
else l = mid + 1;
}

if(nums[l] != k) cout << "-1 -1" << endl;
else
{
cout << l << " ";
int l = 0, r = n - 1;
while(l < r)
{
int mid = (l+r+1) >> 1;
if(nums[mid] <= k) l = mid;
else r = mid-1;
}
cout << l << endl;
}
}

return 0;
}


#include<iostream>

using namespace std;

const int N = 1010;
int a[N][N], b[N][N];

// 二维最核心的插入操作
void insert (int x1, int y1, int x2, int y2, int c)
{
b[x1][y1] += c;
b[x2+1][y1] -= c;
b[x1][y2+1] -= c;
b[x2+1][y2+1] += c;
}

int main()
{
int n, m, q;
scanf("%d%d%d", &n, &m, &q);

for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
}

// 初始化差分数组b
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++) insert(i, j, i, j, a[i][j]);
}

while(q--)
{
int x1, y1, x2, y2, c;
scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &c);
// 每一次进行一次操作
insert(x1,y1,x2,y2,c);
}

for (int i = 1; i <= n; i ++ )
for (int j = 1; j <= m; j ++ )
// 求二维前缀和
b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];

for (int i = 1; i <= n; i ++ )
{
for (int j = 1; j <= m; j ++ ) printf("%d ", b[i][j]);
printf("\n");
}

return 0;
}


#include<iostream>

using namespace std;

const int N = 1e5+10;
int a[N], b[N];

// 差分中唯一操作 在区间【l, r】中对每一个元素进行 + c
void insert(int l, int r, int c)
{
b[l] += c;
b[r+1] -= c;
}

int main()
{
int m, n;
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
}

// 初始化差分数组
for(int i = 1; i <= n; i++)
{
insert(i, i, a[i]); // b[N]是全局变量，在进行insert操作时就已经将b数组弄成了差分数组
}

while(m--)
{
int l, r, c;
scanf("%d%d%d", &l, &r, &c);
insert(l, r, c);
}

for(int i = 1; i <= n; i++)
{
b[i] += b[i-1]; // 求前缀和
printf("%d ", b[i]);
}
return 0;
}


/*
用dijkstra算出原来每个点到 1的最短距离
然后遍历所有点，找到中转点，
使得中转点到当前点距离 + 中转点到 1距离 == 原来的最短距离
其中 d[i]表示 i号点到 1号点的距离
*/

#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>

using namespace std;

#define f first
#define s second

typedef pair<int, int> PII;
const int N = 1e4+10, M = 2e5+10;
int h[N], ne[M], e[M], idx, w[M];
int n, m;
int d[N];
bool st[N];

void add(int a, int b, int c)
{
e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx++;
}

void dijkstra()
{
memset(d, 0x3f, sizeof d);
d[1] = 0;

priority_queue<PII, vector<PII>, greater<PII> > q;
q.push({0, 1});

while(q.size())
{
auto t = q.top();
q.pop();
if(st[t.s]) continue;
st[t.s] = true;
for(int i = h[t.s]; i != -1; i = ne[i])
{
int j = e[i];
if(d[j] > w[i] + t.f)
{
d[j] = w[i] + t.f;
q.push({d[j], j});
}
}
}
}

int main()
{
cin >> n >> m;
memset(h, -1, sizeof h);
while(m--)
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
add(a, b, c), add(b, a, c);
}

dijkstra();

int res = 0;
for(int k = 2; k <= n; k++)
{
int road = 0x3f3f3f3f;
for(int i = h[k]; i != -1; i = ne[i])
{
int j = e[i];
// j作为中转点， 1-k的距离 == 1-j的距离 + j-k的距离
if(d[k] == d[j] + w[i]) road = min(road, w[i]);
}
res += road;
}
cout << res;
return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;
const int N = 1010;
int a[N];

struct Op
{
int id, type, time;
}op[N*2]; // 操作有借有还，所以 * 2

int cmp(Op a, Op b)
{
/*
此处比较函数应该按照以下规则
1、时间从小到大
2、时间相同，还操作在前
3、时间、操作类型都一样，按 id从小到大
*/
if(a.time < b.time) return 1;
else if(a.time == b.time)
{
if(a.type > b.type) return 1;
else if(a.type == b.type)
{
if(a.id < b.id) return 1;
}
}
return 0;
}

int main()
{
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i++) a[i] = i;
int cnt = 0;
while(m--)
{
int id, sta, len;
cin >> id >> sta >> len;
op[cnt++] = {id, 0, sta}; // 取钥匙
op[cnt++] = {id, 1, sta + len}; // 还钥匙
}

sort(op, op+cnt, cmp);

for(int i = 0; i < cnt; i++)
{
if(!op[i].type)
{
for(int j = 1; j <= n; j++)
{
if(a[j] == op[i].id)
{
a[j] = 0;
break;
}
}
}
else
{
for(int j = 1; j <= n; j++)
{
if(!a[j])
{
// 从小到大有空位直接插入即可
a[j] = op[i].id;
break;
}
}
}
}
for(int i = 1; i <= n; i++) cout << a[i] << " ";
return 0;
}