답안 #677896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677896 2023-01-04T14:49:42 Z qwerasdfzxcl 송금 (JOI19_remittance) C++17
0 / 100
1 ms 468 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 *= n;
    }
    return ret;
}

vector<int> i_to_v(int x){
    vector<int> ret;
    for (int i=0;i<n;i++){
        ret.push_back(x%n);
        x /= n;
    }
    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);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -