제출 #1284441

#제출 시각아이디문제언어결과실행 시간메모리
1284441am_aadvik송금 (JOI19_remittance)C++20
15 / 100
278 ms327680 KiB
#include <iostream> #include<vector> #include<map> #include<queue> #define int long long using namespace std; map<vector<int>, bool> mp; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> a(n), b(n), c(n, 0); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i]; mp[a] = 1; queue<vector<int>> q; q.push(a); while(!q.empty()){ auto x = q.front(); q.pop(); bool ok = 1; for(int i = 0; i < n; ++i) ok &= (x[i] == b[i]); if(ok) {cout << "Yes"; exit(0);} for(int i = 0; i < n; ++i) for(int j = 1; (2 * j) <= x[i]; ++j){ x[i] -= (2 * j), x[(i + 1) % n] += j; if(mp.find(x) == mp.end()) mp[x] = 1, q.push(x); x[i] += (2 * j), x[(i + 1) % n] -= j; } } cout << "No"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...