# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
293667 | 2020-09-08T09:24:32 Z | Aldas25 | 송금 (JOI19_remittance) | C++14 | 1000 ms | 87052 KB |
//#pragma GCC optimize("O3") #include <bits/stdc++.h> //#include <ctime> using namespace std; #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr) #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define pb push_back #define f first #define s second typedef long double ld; typedef long long ll; typedef pair<int, int> pii; typedef pair<int, pii> piii; typedef vector<int> vi; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<piii> viii; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 1000100, MAXK = 20; const ll MOD = 1e9+7; const ll INF = 1e16; const ld PI = asin(1) * 2; void setIO () { FAST_IO; } void setIO (string s) { setIO(); freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } int n; ll a[MAXN], b[MAXN]; map<vi, int> d; void bfs () { queue<vi> q; vi st(n); FOR(i, 0, n-1) st[i] = a[i]; d[st] = 1; q.push(st); while (!q.empty()) { st = q.front(); q.pop(); //cout << " st: "; //for (int x : st) cout << " " << x; //cout << " d = " << d[st] << endl; FOR(i, 0, n-1) { vi newSt(n); FOR(j, 0, n-1) newSt[j] = st[j]; if (newSt[i] > 1) { newSt[i] -= 2; newSt[(i+1)%n] ++; } if (d[newSt] == 0) { d[newSt] = d[st] + 1; q.push(newSt); } } } } int main() { setIO(); cin >> n; FOR(i, 0, n-1) cin >> a[i] >> b[i]; bfs (); vi st(n); FOR(i, 0, n-1) st[i] = b[i]; if (d[st] > 0) cout << "Yes\n"; else cout << "No\n"; return 0; } /* 3 10 7 10 10 10 10 ans: yes 3 3 0 0 0 0 0 ans: no */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 512 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 3 ms | 512 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 768 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 38 ms | 2424 KB | Output is correct |
30 | Correct | 38 ms | 2424 KB | Output is correct |
31 | Correct | 38 ms | 2424 KB | Output is correct |
32 | Correct | 38 ms | 2424 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 512 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 3 ms | 512 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 768 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 38 ms | 2424 KB | Output is correct |
30 | Correct | 38 ms | 2424 KB | Output is correct |
31 | Correct | 38 ms | 2424 KB | Output is correct |
32 | Correct | 38 ms | 2424 KB | Output is correct |
33 | Execution timed out | 1097 ms | 87052 KB | Time limit exceeded |
34 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 512 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 3 ms | 512 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 768 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 38 ms | 2424 KB | Output is correct |
30 | Correct | 38 ms | 2424 KB | Output is correct |
31 | Correct | 38 ms | 2424 KB | Output is correct |
32 | Correct | 38 ms | 2424 KB | Output is correct |
33 | Execution timed out | 1097 ms | 87052 KB | Time limit exceeded |
34 | Halted | 0 ms | 0 KB | - |