Submission #381346

# Submission time Handle Problem Language Result Execution time Memory
381346 2021-03-25T06:42:00 Z ne4eHbKa Zagrade (COI20_zagrade) C++17
100 / 100
962 ms 1028 KB
#include <bits/stdc++.h>
using namespace std;
#ifndef _LOCAL
//#pragma GCC optimize("O3,Ofast")
#else
#pragma GCC optimize("O0")
#endif
template<typename t> inline void umin(t &a, const t b) {a = min(a, b);}
template<typename t> inline void umax(t &a, const t b) {a = max(a, b);}
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef int8_t byte;
ll time() {return chrono::system_clock().now().time_since_epoch().count();}
mt19937 rnd(time());
#define ft first
#define sd second
#define len(f) int((f).size())
#define bnd(f) (f).begin(), (f).end()
#define _ <<' '<<
const int inf = 1e9 + 5;
const ll inf64 = 4e18 + 5;
const int md = 998244353;
namespace MD {
    void add(int &a, const int b) {if((a += b) >= md) a -= md;}
    void sub(int &a, const int b) {if((a -= b) < 0) a += md;}
    int prod(const int a, const int b) {return ll(a) * b % md;}
};

signed main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, q;
    cin >> n >> q;
    int f[n];
    int k = 0;
    char ans[n];
    for(int i = 0; i < n; ++i) {
        f[k++] = i;
        if(k > 1) {
            cout << "? " << f[k - 2] + 1 _ f[k - 1] + 1 << endl;
            int res; cin >> res;
            if(res) {
                ans[f[k - 2]] = '(';
                ans[f[k - 1]] = ')';
                k -= 2;
            }
        }
    }
    for(int i = 0; i < k; ++i)
        ans[f[i]] = i + i < k ? ')' : '(';
    cout << "! ";
    for(int i = 0; i < n; ++i)
        cout << ans[i];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 5 ms 364 KB Output is correct
3 Correct 9 ms 364 KB Output is correct
4 Correct 10 ms 364 KB Output is correct
5 Correct 9 ms 364 KB Output is correct
6 Correct 8 ms 364 KB Output is correct
7 Correct 10 ms 364 KB Output is correct
8 Correct 9 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 10 ms 364 KB Output is correct
3 Correct 10 ms 364 KB Output is correct
4 Correct 11 ms 364 KB Output is correct
5 Correct 9 ms 364 KB Output is correct
6 Correct 11 ms 364 KB Output is correct
7 Correct 7 ms 364 KB Output is correct
8 Correct 10 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 499 ms 552 KB Output is correct
3 Correct 852 ms 604 KB Output is correct
4 Correct 781 ms 752 KB Output is correct
5 Correct 901 ms 748 KB Output is correct
6 Correct 948 ms 876 KB Output is correct
7 Correct 796 ms 956 KB Output is correct
8 Correct 900 ms 648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 943 ms 1028 KB Output is correct
3 Correct 758 ms 1004 KB Output is correct
4 Correct 896 ms 984 KB Output is correct
5 Correct 962 ms 876 KB Output is correct
6 Correct 879 ms 928 KB Output is correct
7 Correct 762 ms 684 KB Output is correct
8 Correct 838 ms 620 KB Output is correct