Submission #930030

# Submission time Handle Problem Language Result Execution time Memory
930030 2024-02-18T09:13:24 Z MuntherCarrot Zagrade (COI20_zagrade) C++14
100 / 100
541 ms 1368 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// #define endl '\n'
#define all(x) x.begin(),x.end()
const int MOD = 1e9 + 7, SZ = 1e5 + 100, MX = 1e9;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, q;
    cin >> n >> q;
    int p[n+2], s[n+1]={}, x = n/2;
    for(int i=1;i<=n;i++)
        p[i] = i-1;
    for(int i=1;i<=n;i++){
        if(p[i] == 0)
            continue;
        int ans;
        cout.flush() << "? " << p[i] << ' ' << i << endl;
        cin >> ans;
        if(ans == 1){
            s[i] = 2;
            s[p[i]] = 1;
            x--;
            p[i+1] = p[p[i]];
        }
    }
    int a = x, b = x;
    for(int i=1;i<=n;i++){
        if(s[i])
            continue;
        if(a){
            a--;
            s[i] = 2;
        }
        else
            s[i] = 1;
    }
    cout.flush() << "! ";
    for(int i=1;i<=n;i++)
        cout.flush() << (s[i] == 2 ? ')' : '(');
    return 0;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:27:16: warning: unused variable 'b' [-Wunused-variable]
   27 |     int a = x, b = x;
      |                ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 4 ms 596 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 267 ms 1368 KB Output is correct
3 Correct 469 ms 1364 KB Output is correct
4 Correct 462 ms 1208 KB Output is correct
5 Correct 526 ms 1208 KB Output is correct
6 Correct 528 ms 1204 KB Output is correct
7 Correct 474 ms 1204 KB Output is correct
8 Correct 474 ms 1208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 502 ms 1204 KB Output is correct
3 Correct 487 ms 1208 KB Output is correct
4 Correct 541 ms 1208 KB Output is correct
5 Correct 487 ms 1204 KB Output is correct
6 Correct 483 ms 1204 KB Output is correct
7 Correct 513 ms 1204 KB Output is correct
8 Correct 522 ms 1208 KB Output is correct