답안 #672407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
672407 2022-12-16T02:25:57 Z horiseun Zagrade (COI20_zagrade) C++11
0 / 100
0 ms 208 KB
#include <iostream>
#include <vector>
#include <stack>
#include <cstring>
#include <algorithm>
using namespace std;

int n, q, emp;
stack<int> unpaired;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> q;
    string ans(n + 1, ' ');
    unpaired.push(0);
    for (int i = 1; i < n; i++) {
        if (unpaired.empty()) {
            unpaired.push(i);
            continue;
        }
        cout << "? " << unpaired.top() << " " << i << "\n";
        cout.flush();
        int res; cin >> res;
        if (res) {
            ans[unpaired.top()] = '(';
            ans[i] = ')';
            unpaired.pop();
        } else {
            unpaired.push(i);
        }
    }

    emp = unpaired.size() / 2;
    while (!unpaired.empty()) {
        if (unpaired.size() <= emp) ans[unpaired.top()] = ')';
        else ans[unpaired.top()] = '(';
        unpaired.pop();
    }

    cout << "! " << ans << "\n";
    cout.flush();

}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:38:29: warning: comparison of integer expressions of different signedness: 'std::stack<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |         if (unpaired.size() <= emp) ans[unpaired.top()] = ')';
      |             ~~~~~~~~~~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -