Submission #232424

# Submission time Handle Problem Language Result Execution time Memory
232424 2020-05-17T01:01:12 Z limabeans Remittance (JOI19_remittance) C++17
15 / 100
1000 ms 85952 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 10;









int n;
vector<int> a, b;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n;
    a.resize(n);
    b.resize(n);
    
    for (int i=0; i<n; i++) {
	cin>>a[i]>>b[i];
    }

    set<vector<int>> ss;


    queue<vector<int>> qq;
    qq.push(a);


    auto gen = [](vector<int> v) {
	int n = v.size();
	vector<vector<int>> res;
	for (int i=0; i<n; i++) {
	    if (v[i]>=2) {
		vector<int> w = v;
		w[i]-=2;
		w[(i+1)%n]++;
		res.push_back(w);
	    }
	    
	}
	return res;
    };

    while (qq.size()) {
	auto at = qq.front(); qq.pop();
	ss.insert(at);
	for (auto w: gen(at)) {
	    if (!ss.count(w)) {
		ss.insert(w);
		qq.push(w);
	    }
	}
    }

    if (ss.count(b)) out("Yes");
    out("No");


    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 7 ms 512 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 6 ms 512 KB Output is correct
24 Correct 10 ms 640 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
29 Correct 51 ms 2260 KB Output is correct
30 Correct 43 ms 2296 KB Output is correct
31 Correct 42 ms 2168 KB Output is correct
32 Correct 42 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 7 ms 512 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 6 ms 512 KB Output is correct
24 Correct 10 ms 640 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
29 Correct 51 ms 2260 KB Output is correct
30 Correct 43 ms 2296 KB Output is correct
31 Correct 42 ms 2168 KB Output is correct
32 Correct 42 ms 2176 KB Output is correct
33 Execution timed out 1093 ms 85952 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 7 ms 512 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 6 ms 512 KB Output is correct
24 Correct 10 ms 640 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
29 Correct 51 ms 2260 KB Output is correct
30 Correct 43 ms 2296 KB Output is correct
31 Correct 42 ms 2168 KB Output is correct
32 Correct 42 ms 2176 KB Output is correct
33 Execution timed out 1093 ms 85952 KB Time limit exceeded
34 Halted 0 ms 0 KB -