Submission #706426

# Submission time Handle Problem Language Result Execution time Memory
706426 2023-03-06T14:41:32 Z vjudge1 Zagrade (COI20_zagrade) C++17
100 / 100
1074 ms 1080 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 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 8 ms 256 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 10 ms 208 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 429 ms 1076 KB Output is correct
3 Correct 845 ms 1080 KB Output is correct
4 Correct 915 ms 1072 KB Output is correct
5 Correct 793 ms 1080 KB Output is correct
6 Correct 884 ms 976 KB Output is correct
7 Correct 747 ms 1072 KB Output is correct
8 Correct 897 ms 1072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1074 ms 976 KB Output is correct
3 Correct 706 ms 1080 KB Output is correct
4 Correct 835 ms 1068 KB Output is correct
5 Correct 969 ms 1072 KB Output is correct
6 Correct 779 ms 1080 KB Output is correct
7 Correct 886 ms 1080 KB Output is correct
8 Correct 549 ms 1080 KB Output is correct