답안 #774215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
774215 2023-07-05T13:05:45 Z vjudge1 Zagrade (COI20_zagrade) C++17
71 / 100
659 ms 668 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define endl "\n"
#define ll long long
#define N 200005
#define pb push_back

int main(){
	lalala;
	int n,q;cin>>n>>q;
	stack<int> s;
	char str[n+1];
	for(int i=1;i<=n;i++){
		if(s.size()){
			int a=s.top();
			cout<<"? "<<a<<" "<<i<<endl;
			int x;cin>>x;
			if(x==1){
				str[i]=')';
				str[a]='(';
				s.pop();
			}
			else{
				s.push(i);
			}
		}
		else{
			s.push(i);
		}
	}
	for(int i=1;i<=s.size()/2;i++){
		str[s.top()]='(';
		s.pop();
	}
	for(int i=1;i<=s.size();i++){
		str[s.top()]=')';
		s.pop();
	}
	cout<<"! ";
	for(int i=1;i<=n;i++)cout<<str[i];
	cout<<endl;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::stack<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i=1;i<=s.size()/2;i++){
      |              ~^~~~~~~~~~~~
zagrade.cpp:36:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::stack<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for(int i=1;i<=s.size();i++){
      |              ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 8 ms 316 KB Output is correct
8 Correct 5 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 5 ms 208 KB Mismatch at position 1. Expected ), found
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 320 ms 388 KB Output is correct
3 Correct 648 ms 384 KB Output is correct
4 Correct 659 ms 384 KB Output is correct
5 Correct 637 ms 392 KB Output is correct
6 Correct 635 ms 392 KB Output is correct
7 Correct 656 ms 668 KB Output is correct
8 Correct 608 ms 392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found .
2 Halted 0 ms 0 KB -