Submission #413683

#TimeUsernameProblemLanguageResultExecution timeMemory
413683rabbitsthecatRemittance (JOI19_remittance)C++17
0 / 100
1086 ms380 KiB
#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; auto bfs = [&] (vector <int> v, auto&& bfs) -> void { reachable[v] = true; for(int i = 0; i < (int)v.size(); i++) { for(int j = 2; j <= v[i]; j += 2) { v[i] -= j; if (i + 1 == n) v[0] += (j / 2); else v[i + 1] += (j / 2); bfs(v, bfs); if (i + 1 == n) v[0] -= (j / 2); else v[i + 1] -= (j / 2); if (i - 1 < 0) v[n - 1] += (j / 2); else v[i - 1] += (j / 2); bfs(v, bfs); if (i - 1 < 0) v[n - 1] -= (j / 2); else v[i - 1] -= (j / 2); v[i] += j; } } }; bfs(left, bfs); if (reachable[right]) cout << "YES\n"; else cout << "NO\n"; } /* C:\Users\kenne\OneDrive\Desktop\competitive_programming\main.cpp */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...