Skip to content

Commit 17a6b0c

Browse files
committed
Some AGC
1 parent 30355bb commit 17a6b0c

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

Atcoder/AGC 045-A.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <array>
2+
#include <cstring>
3+
#include <iostream>
4+
using namespace std;
5+
typedef long long ll;
6+
7+
ll a[200], basis[60];
8+
9+
bool in_span(ll val) {
10+
for (int i = 59; ~i; i--)
11+
if (val & (1ll << i)) val ^= basis[i];
12+
return val == 0;
13+
}
14+
15+
void add_vec(ll val) {
16+
for (int i = 59; ~i; i--)
17+
if (val & (1ll << i))
18+
if (basis[i]) val ^= basis[i];
19+
else {
20+
basis[i] = val;
21+
return;
22+
}
23+
}
24+
25+
int main() {
26+
cin.tie(0)->sync_with_stdio(0);
27+
int t;
28+
cin >> t;
29+
while (t--) {
30+
int n;
31+
cin >> n;
32+
for (int i = 0; i < n; i++) cin >> a[i];
33+
string s;
34+
cin >> s;
35+
memset(basis, 0, sizeof basis);
36+
bool win = true;
37+
for (int i = n - 1; ~i && win; i--) {
38+
if (!in_span(a[i])) {
39+
if (s[i] == '0')
40+
add_vec(a[i]);
41+
else
42+
win = false;
43+
}
44+
}
45+
cout << "10"[win] << '\n';
46+
}
47+
}

Atcoder/AGC 055-B.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <iostream>
2+
#include <vector>
3+
using namespace std;
4+
5+
char shift(char c, int offset) { return 'A' + ((c - 'A') + offset) % 3; }
6+
7+
bool consec(vector<char>& v) {
8+
return v.size() > 2 && v[v.size() - 3] == v.back() &&
9+
v[v.size() - 2] == v.back();
10+
}
11+
12+
int main() {
13+
cin.tie(0)->sync_with_stdio(0);
14+
int n;
15+
cin >> n;
16+
vector<char> stck[2];
17+
for (int i : {0, 1}) {
18+
char curr = '-';
19+
for (int j = 0; j < n; j++) {
20+
char c;
21+
cin >> c;
22+
c = shift(c, n - j);
23+
stck[i].push_back(c);
24+
if (consec(stck[i])) {
25+
stck[i].pop_back();
26+
stck[i].pop_back();
27+
stck[i].pop_back();
28+
}
29+
}
30+
}
31+
if (stck[0] == stck[1])
32+
cout << "YES";
33+
else
34+
cout << "NO";
35+
}

0 commit comments

Comments
 (0)