Submission #677899

# Submission time Handle Problem Language Result Execution time Memory
677899 2023-01-04T14:55:26 Z qwerasdfzxcl Remittance (JOI19_remittance) C++17
0 / 100
1 ms 340 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;
          	if (na[(i+1%n)] > 6) continue;
 
            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:43:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
remittance.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -