Submission #920293

# Submission time Handle Problem Language Result Execution time Memory
920293 2024-02-02T12:18:18 Z ErJ Zagrade (COI20_zagrade) C++17
100 / 100
484 ms 1360 KB
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>


//#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<pair<ll, ll>>
#define pp pair<ll, ll>
#define qi queue<ll>
#define qp queue<pp>
#define pqi priority_queue<ll>
#define pqp priority_queue<pp>
#define mi map<ll, ll>
#define mpi map<pp, ll>
#define mip map<ll, pp>
#define mpp map<pp, pp>
#define mb map<ll, bool>
#define si set<ll>
#define sp set<pp>
#define mod 1000000007
#define rep(a, b) for(int a = 0; a < (b); a++)
#define inf 1000000000000000000

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> pos(n);
    vector<int> left(n);
    rep(i, n) {
        left[i] = i - 1;
        pos[i] = 0;
    }
    int x = 0;
    for (int i = 1; i < n; i++) {
        if (left[i] < 0) continue;
        cout << "? " << left[i] + 1 << " " << i + 1 << endl;
        int ans;
        cin >> ans;
        if (ans == 1) {
            x++;
            pos[left[i]] = 1;
            pos[i] = -1;
            if (i < n - 1) {
                left[i + 1] = left[left[i]];
            }            
        }
    }
    x *= 2;
    int y = (n - x) / 2;
    int akt = 0;
    cout << "! ";
    for (int i = 0; i < n; i++) {
        if (pos[i] == 0) {
            if (akt < y) {
                pos[i] = -1;
            }
            else {
                pos[i] = 1;
            }
            akt++;
        }
        if (pos[i] == 1) {
            cout << '(';
        }
        else {
            cout << ')';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 3 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 3 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 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 0 ms 344 KB Output is correct
2 Correct 201 ms 1228 KB Output is correct
3 Correct 416 ms 1224 KB Output is correct
4 Correct 437 ms 1228 KB Output is correct
5 Correct 425 ms 1360 KB Output is correct
6 Correct 474 ms 1224 KB Output is correct
7 Correct 460 ms 1356 KB Output is correct
8 Correct 435 ms 1232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 436 ms 1224 KB Output is correct
3 Correct 421 ms 1228 KB Output is correct
4 Correct 452 ms 1232 KB Output is correct
5 Correct 457 ms 1236 KB Output is correct
6 Correct 484 ms 1224 KB Output is correct
7 Correct 475 ms 1228 KB Output is correct
8 Correct 446 ms 1232 KB Output is correct