Submission #583780

# Submission time Handle Problem Language Result Execution time Memory
583780 2022-06-26T07:55:57 Z eecs Zagrade (COI20_zagrade) C++17
100 / 100
901 ms 1188 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n >> *new int;
    auto ask = [&](int a, int b) {
        cout << "? " << a + 1 << " " << b + 1 << endl;
        return cin >> a, a;
    };
    string res(n, '(');
    vector<int> st;
    for (int i = 0; i < n; i++) {
        if (st.empty() || !ask(st.back(), i)) st.push_back(i);
        else res[i] = ')', st.pop_back();
    }
    for (int i = 0; i < st.size() / 2; i++) {
        res[st[i]] = ')';
    }
    cout << "! " << res << endl;
    return 0;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < st.size() / 2; i++) {
      |                     ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 11 ms 208 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
8 Correct 6 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 10 ms 208 KB Output is correct
4 Correct 11 ms 304 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 6 ms 304 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 372 ms 380 KB Output is correct
3 Correct 664 ms 372 KB Output is correct
4 Correct 736 ms 384 KB Output is correct
5 Correct 607 ms 380 KB Output is correct
6 Correct 897 ms 380 KB Output is correct
7 Correct 812 ms 804 KB Output is correct
8 Correct 649 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 824 ms 1188 KB Output is correct
3 Correct 848 ms 716 KB Output is correct
4 Correct 522 ms 776 KB Output is correct
5 Correct 822 ms 704 KB Output is correct
6 Correct 824 ms 1000 KB Output is correct
7 Correct 849 ms 632 KB Output is correct
8 Correct 901 ms 400 KB Output is correct