답안 #706364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706364 2023-03-06T10:33:07 Z vjudge1 Zagrade (COI20_zagrade) C++17
0 / 100
0 ms 208 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
// #define endl '\n'

const int M = 4e5+5, MOD = 998244353;
char s[M];
signed main() {
    cin.tie(0)->sync_with_stdio(0);
    
    int n, q;
    cin >> n >> q;

    int cnt = n/2;
    stack<int> st;
    for (int i = 1; i <= n; i++) {
        if (!st.size()) st.push(i);
        else {
            cout << "? " << st.top() << ' ' << i << endl;
            int x;
            cin >> x;

            if (x) cnt--, s[i]=')', s[st.top()] = '(', st.pop();
            else st.push(i);
        }
    }

    for (int i = 1; i <= n; i++)
        if (!s[i]) cnt?s[i]=')', cnt--:s[i]='(';
    for (int i = 1; i <= n; i++) cout << s[i]; cout << endl;

    return 0;
}
/*
1234567890123456
))(()(())()(()()
)))()(())())()()
16 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0 1
*/

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:31:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   31 |     for (int i = 1; i <= n; i++) cout << s[i]; cout << endl;
      |     ^~~
zagrade.cpp:31:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   31 |     for (int i = 1; i <= n; i++) cout << s[i]; cout << endl;
      |                                                ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Incorrect query ()
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Incorrect query )(
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Incorrect query (())
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Incorrect query ))((
2 Halted 0 ms 0 KB -