Skip to content

Commit 910add6

Browse files
authored
Create 2019-D-A.cpp
1 parent a895743 commit 910add6

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

kick-start/2019-D-A.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include<bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
#define ms(x,v) memset(x,(v), sizeof(x))
6+
#define msn(x,v,n) memset(x,(v),sizeof(x[0]) * n)
7+
#define INF 0x3f3f3f3f
8+
9+
typedef long long LL;
10+
typedef pair<int,int> PII;
11+
12+
const int MAXN = 1000 + 3;
13+
14+
15+
16+
int n,K;
17+
int main(int argc, char const *argv[])
18+
{
19+
cin.tie(0);
20+
ios :: sync_with_stdio(0);
21+
22+
std::cout.precision(8);
23+
std::cout.setf( std::ios::fixed, std:: ios::floatfield );
24+
int T;
25+
cin >> T;
26+
27+
const int BASE = 1024;
28+
bool xorodd[BASE];
29+
for(int i=0 ; i<= BASE ; ++i){
30+
xorodd[i] = bitset<11>(i).count()&1;
31+
}
32+
for(int t =1; t <= T ; ++t)
33+
{
34+
cout << "Case #"<<t << ":";
35+
int n,q;
36+
cin >> n >> q;
37+
std::set<int> odd;
38+
for(int i=1 ; i<=n ; ++i){
39+
int x;
40+
cin >> x;
41+
if(xorodd[x])odd.insert(i);
42+
}
43+
while(q--){
44+
int idx,x;
45+
cin >> idx >> x;
46+
idx++;
47+
if(odd.count(idx))odd.erase(idx);
48+
if(xorodd[x])odd.insert(idx);
49+
if(odd.size()&1){
50+
int first = *odd.begin();
51+
int end = *(--odd.end());
52+
cout <<" "<< max(end -1, n - first);
53+
}else cout << " " << n;
54+
}
55+
cout << "\n";
56+
}
57+
58+
return 0;
59+
}

0 commit comments

Comments
 (0)