이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define sp " "
//#define endl "\n"
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 200005
int ask(int a, int b){
cout<<"? "<<a<<sp<<b<<endl;
int res;
cin>>res;
return res;
}
int32_t main(){
//fileio();
//fastio();
int n, q;
cin>>n>>q;
vector<int> arr(n + 5, 0);
map<int ,int> pos;
int curr = 0, it = 2;
stack<int> last;
last.push(1);
while(it <= n){
if (last.empty())
{
last.push(it);
it++;
continue;
}
int res = ask(last.top(), it);
if (res){
arr[last.top()] = 1, arr[it] = -1;
last.pop();
}
else last.push(it);
it++;
}
int m = last.size();
int tmp = m / 2;
while(tmp > 0){
arr[last.top()] = 1;
last.pop();
tmp--;
}
while(last.size()){
arr[last.top()] = -1;
last.pop();
}
cout<<"! ";
for (int i = 1; i <= n; i++){
cout<<((arr[i] == 1) ? '(' : ')');
}
cout<<endl;
//cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
컴파일 시 표준 에러 (stderr) 메시지
zagrade.cpp: In function 'int32_t main()':
zagrade.cpp:31:6: warning: unused variable 'curr' [-Wunused-variable]
31 | int curr = 0, it = 2;
| ^~~~
# | 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... |