답안 #1084620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1084620 2024-09-06T14:26:58 Z shiocan Prize (CEOI22_prize) C++17
0 / 100
166 ms 5556 KB
#include <bits/stdc++.h>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
/*
    #define cin fin
    #define cout fout
    string __fname = ""; ifstream fin(__fname + ".in"); ofstream fout(__fname + ".out");
*/
#define ull unsigned long long 
#define ll long long
// #define int long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
int mod = 1e9 + 7; 
// const int inf = 1e18;
const int N = 1e6 + 10;

void solve(){   
    int n, k, q, t;
    cin >> n >> k >> q >> t;

    vector<int> ans(n + 5, 0ll);

    int root = -1;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;        
    
        if(x == -1)
            root = i;
    }

    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
    }

    vector<int> aux; // size q
    aux.push_back(root);
    cout << root << ' ';
    k--;
    for(int i = 1; i <= n && k; i++){
        if(i != root)
            cout << i << ' ', k--, aux.push_back(i);
    }
    cout << '\n';
    cout.flush();

    for(int i = 1; i <= q; i++)
        cout << "? " << root << ' ' << aux[i] << '\n';

    cout << "!" << '\n';
    cout.flush();

    for(int i = 1; i <= q; i++){
        int x;
        cin >> x >> x >> x >> x;

        ans[aux[i]] = x;
    }

    vector<int> res(t + 5, 0ll);

    for(int i = 1; i <= t; i++){
        int x, y;
        cin >> x >> y;

        res[i] = ans[x] + ans[y];
    }

    for(int i = 1; i <= t; i++)
        cout << res[i] << ' ' << res[i] << '\n';
    cout.flush();
}

int32_t main(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 101 ms 3180 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 133 ms 2940 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 61 ms 2468 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 121 ms 4836 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 166 ms 5556 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -