# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1107395 | TrieTr | Zagrade (COI20_zagrade) | C++14 | 801 ms | 1952 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
void local() {
#define taskname ""
if(fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
}
#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
template <class X, class Y> bool mini(X& x, Y y) {return x > y ? x = y, true : false;}
template <class X, class Y> bool maxi(X& x, Y y) {return x < y ? x = y, true : false;}
const int N = 1e6 + 5;
int n, q;
bool ask(int a, int b) {
a++; b++;
cout << "? " << a << ' ' << b << endl;
bool ok; cin >> ok; return ok;
}
void answer(string s) {
cout << "! " << s << endl;
exit(0);
}
bool type[N];
int main() {
fastio; local();
cin >> n >> q;
string s(n, '#'); stack<int>st; st.emplace(0);
int cur = n;
for(int i = 1; i < n; i++) {
if(st.empty()) st.emplace(i);
else {
if(ask(st.top(), i)) {
s[st.top()] = '('; s[i] = ')'; st.pop(); cur -= 2;
}
else st.emplace(i);
}
}
for(int i = 0; i < n; i++) {
if(s[i] == '#') {
if(cur) s[i] = ')', cur -= 2;
else s[i] = '(';
}
}
answer(s);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |