Submission #677897

# Submission time Handle Problem Language Result Execution time Memory
677897 2023-01-04T14:50:51 Z qwerasdfzxcl Remittance (JOI19_remittance) C++17
0 / 100
3 ms 692 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
bool visited[300300];
int n;

int v_to_i(vector<int> v){
    int pw = 1, ret = 0;
    for (int i=0;i<n;i++){
        ret += pw * v[i];
        pw *= 6;
    }
    return ret;
}

vector<int> i_to_v(int x){
    vector<int> ret;
    for (int i=0;i<n;i++){
        ret.push_back(x%6);
        x /= 6;
    }
    return ret;
}

void dfs(int s){
    visited[s] = 1;
    auto a = i_to_v(s);
    for (int i=0;i<n;i++){
        for (int j=1;j*2<=a[i];j++){
            auto na = a;
            na[i] -= j*2;
            na[(i+1)%n] += j;

            int v = v_to_i(na);
            if (!visited[v]) dfs(v);
        }
    }
}

int main(){
    scanf("%d", &n);
    vector<int> a, b;
    for (int i=0;i<n;i++){
        int x, y;
        scanf("%d %d", &x, &y);
        a.push_back(x);
        b.push_back(y);
    }


    dfs(v_to_i(a));
    if (visited[v_to_i(b)]) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
remittance.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 312 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Runtime error 3 ms 692 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 312 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Runtime error 3 ms 692 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 312 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Runtime error 3 ms 692 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -