Submission #413723

# Submission time Handle Problem Language Result Execution time Memory
413723 2021-05-29T09:33:38 Z rabbitsthecat Remittance (JOI19_remittance) C++17
0 / 100
976 ms 29560 KB
#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;
				
				if (i + 1 == n) {
					v[0] += 1;
					bfs(bfs);
					v[0] -= 1;
				}
				else {
					v[i + 1] += 1;
					bfs(bfs);
					v[i + 1] -= 1;
				}
				
				if (i - 1 >= 0) {
					v[i - 1] += 1;
					bfs(bfs);
					v[i - 1] -= 1;
				}
				else {
					v[n - 1] += 1;
					bfs(bfs);
					v[n - 1] -= 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 Correct 64 ms 2560 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 352 KB Output is correct
7 Correct 5 ms 716 KB Output is correct
8 Correct 3 ms 204 KB Output is correct
9 Correct 4 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 4 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 218 ms 9760 KB Output is correct
22 Correct 3 ms 460 KB Output is correct
23 Correct 116 ms 6520 KB Output is correct
24 Correct 976 ms 29560 KB Output is correct
25 Incorrect 44 ms 2680 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 64 ms 2560 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 352 KB Output is correct
7 Correct 5 ms 716 KB Output is correct
8 Correct 3 ms 204 KB Output is correct
9 Correct 4 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 4 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 218 ms 9760 KB Output is correct
22 Correct 3 ms 460 KB Output is correct
23 Correct 116 ms 6520 KB Output is correct
24 Correct 976 ms 29560 KB Output is correct
25 Incorrect 44 ms 2680 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 64 ms 2560 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 352 KB Output is correct
7 Correct 5 ms 716 KB Output is correct
8 Correct 3 ms 204 KB Output is correct
9 Correct 4 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 4 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 218 ms 9760 KB Output is correct
22 Correct 3 ms 460 KB Output is correct
23 Correct 116 ms 6520 KB Output is correct
24 Correct 976 ms 29560 KB Output is correct
25 Incorrect 44 ms 2680 KB Output isn't correct
26 Halted 0 ms 0 KB -