#include "bits/stdc++.h"
using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
#define uwu ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize("Ofast")
const int INF = 1e9 + 7;
const long long INF2 = 1e17;
int main(void) {
uwu
int n; cin >> n;
vector <int> left(n), right(n);
ffor(n) cin >> left[i] >> right[i];
map <vector <int>, bool> reachable;
vector <int> v = left;
auto bfs = [&] (auto&& bfs) -> void {
if (reachable[v]) return;
reachable[v] = true;
for(int i = 0; i < (int)v.size(); i++) {
if (v[i] >= 2) {
v[i] -= 2;
v[(i + 1) % n] += 1;
bfs(bfs);
v[(i + 1) % n] -= 1;
v[(i + n - 1) % n] += 1;
bfs(bfs);
v[(i + n - 1) % n] -= 1;
v[i] += 2;
}
}
};
bfs(bfs);
if (reachable[right]) cout << "YES\n";
else cout << "NO\n";
}
/*
C:\Users\kenne\OneDrive\Desktop\competitive_programming\main.cpp
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
2500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
2500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
2500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |