Submission #1043944

# Submission time Handle Problem Language Result Execution time Memory
1043944 2024-08-05T05:02:23 Z 변재우(#11009) Prize (CEOI22_prize) C++17
0 / 100
372 ms 120528 KB
#include <bits/stdc++.h>
using namespace std;

const int Nmax=1000010;
int N, K, Q, T, R1, R2, A[Nmax], B[Nmax], C[Nmax], D[Nmax];
int X[Nmax], Y[Nmax];
vector<int> adj1[Nmax], adj2[Nmax];
vector<int> V;
vector<pair<int, int>> P;

int main() {
    scanf("%d%d%d%d", &N, &K, &Q, &T);
    for(int i=1; i<=N; i++) {
        int p; scanf("%d", &p);
        if(p<0) R1=i;
        else adj1[p].push_back(i);
    }
    for(int i=1; i<=N; i++) {
        int p; scanf("%d", &p);
        if(p<0) R2=i;
        else adj2[p].push_back(i);
    }
    V.push_back(R1);
    for(int i=1; i<=N && V.size()<K-1; i++) if(i!=R1 && i!=R2) V.push_back(i);
    V.push_back(R2);
    for(int i:V) printf("%d ", i); puts("");
    fflush(stdout);
    for(int i=0; i<K-1; i++) printf("? %d %d\n", V[i], V[i+1]);
    puts("!");
    fflush(stdout);
    for(int i=2; i<=K; i++)
        scanf("%d%d%d%d", A+i, B+i, C+i, D+i);
    for(int i=2; i<=K; i++) X[i]=X[i-1]-A[i]+B[i];
    for(int i=K-1; i>=1; i--) Y[i]=Y[i+1]-D[i+1]+C[i+1];
    for(int i=1; i<=T; i++) {
        int a, b; scanf("%d%d", &a, &b);
        P.push_back({a, b});
    }
    for(auto [a, b]:P) {
        int pa;
        if(a==R1) pa=1;
        else if(a==R2) pa=K;
        else pa=lower_bound(V.begin()+1, V.end()-1, a)-V.begin()+1;
        int pb;
        if(b==R1) pb=1;
        else if(b==R2) pb=K;
        else pb=lower_bound(V.begin()+1, V.end()-1, b)-V.begin()+1;
        if(pa>pb) swap(pa, pb);
        printf("%d %d\n", X[pb]-X[pa]+2*A[pa+1], Y[pa]-Y[pb]+2*D[pb]);
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:24:34: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     for(int i=1; i<=N && V.size()<K-1; i++) if(i!=R1 && i!=R2) V.push_back(i);
      |                          ~~~~~~~~^~~~
Main.cpp:26:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   26 |     for(int i:V) printf("%d ", i); puts("");
      |     ^~~
Main.cpp:26:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   26 |     for(int i:V) printf("%d ", i); puts("");
      |                                    ^~~~
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d%d%d%d", &N, &K, &Q, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:14:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         int p; scanf("%d", &p);
      |                ~~~~~^~~~~~~~~~
Main.cpp:19:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         int p; scanf("%d", &p);
      |                ~~~~~^~~~~~~~~~
Main.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         scanf("%d%d%d%d", A+i, B+i, C+i, D+i);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:36:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         int a, b; scanf("%d%d", &a, &b);
      |                   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 120 ms 79404 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 174 ms 88952 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 119 ms 87972 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 372 ms 119912 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 329 ms 120528 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -