답안 #1043993

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1043993 2024-08-05T05:58:05 Z 변재우(#11009) Prize (CEOI22_prize) C++17
0 / 100
379 ms 16580 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], I[Nmax];
int X[Nmax], Y[Nmax];
vector<int> V;
vector<pair<int, int>> P;

int main() {
    cin>>N>>K>>Q>>T;
    for(int i=1; i<=N; i++) {
        int p; cin>>p;
        if(p<0) R1=i;
    }
    for(int i=1; i<=N; i++) {
        int p; cin>>p;
        if(p<0) R2=i;
    }
    if(R1==R2) {
        V.push_back(R1);
        for(int i=1; i<=N && V.size()<K; i++) if(i!=R1) V.push_back(i);
    }
    else {
        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=0; i<V.size(); i++) I[V[i]]=i+1;
    for(int i:V) cout<<i<<" ";
    cout<<"\n";
    cout.flush();
    for(int i=0; i<K-1; i++) cout<<"? "<<V[i]<<" "<<V[i+1]<<"\n";
    cout<<"!\n";
    cout.flush();
    for(int i=2; i<=K; i++) cin>>A[i]>>B[i]>>C[i]>>D[i];
    for(int i=2; i<=K; i++) X[i]=X[i-1]-A[i]+B[i];
    if(R1!=R2) for(int i=K-1; i>=1; i--) Y[i]=Y[i+1]-D[i+1]+C[i+1];
    else for(int i=2; i<=K; i++) Y[i]=Y[i-1]-C[i]+D[i];
    for(int i=1; i<=T; i++) {
        int a, b; cin>>a>>b;
        P.push_back({a, b});
    }
    for(auto [a, b]:P) {
        int pa=I[a], pb=I[b];
        if(pa>pb) swap(pa, pb);
        if(pa==pb) cout<<"0 0\n";
        else if(R1!=R2) cout<<X[pb]-X[pa]+2*A[pa+1]<<" "<<Y[pa]-Y[pb]+2*D[pb]<<"\n";
        else cout<<X[pb]-X[pa]+2*A[pa+1]<<" "<<Y[pb]-Y[pa]+2*C[pa+1]<<"\n";
    }
    cout.flush();
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |         for(int i=1; i<=N && V.size()<K; i++) if(i!=R1) V.push_back(i);
      |                              ~~~~~~~~^~
Main.cpp:26:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |         for(int i=1; i<=N && V.size()<K-1; i++) if(i!=R1 && i!=R2) V.push_back(i);
      |                              ~~~~~~~~^~~~
Main.cpp:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i=0; i<V.size(); i++) I[V[i]]=i+1;
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 230 ms 16580 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 282 ms 13012 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 184 ms 13336 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 340 ms 13848 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 379 ms 13016 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -