Submission #774202

# Submission time Handle Problem Language Result Execution time Memory
774202 2023-07-05T12:55:47 Z vjudge1 Zagrade (COI20_zagrade) C++17
71 / 100
846 ms 600 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];
	s.push(1);
	str[1]='(';
	for(int i=2;i<=n;i++){
		if(s.size()){
			int a=s.top();
			cout<<"? "<<a<<" "<<i<<endl;
			int x;cin>>x;
			if(x==1){
				str[i]=')';
				s.pop();
			}
			else{
				str[i]='(';
				s.push(i);
			}
		}
		else{
			s.push(i);
			str[i]='(';
			continue;
		}
	}
	int i=1;
	while(s.size()){
		char a='(';
		if(i>s.size()/2)a=')';
		str[s.top()]=a;
		s.pop();
		i++;
	}
	cout<<"! ";
	for(i=1;i<=n;i++)cout<<str[i];
	cout<<endl;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:39:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::stack<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   if(i>s.size()/2)a=')';
      |      ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 8 ms 312 KB Mismatch at position 501. Expected (, found )
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 197 ms 400 KB Output is correct
3 Correct 795 ms 388 KB Output is correct
4 Correct 846 ms 392 KB Output is correct
5 Correct 643 ms 392 KB Output is correct
6 Correct 582 ms 384 KB Output is correct
7 Correct 562 ms 600 KB Output is correct
8 Correct 619 ms 396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 3. Expected (, found )
2 Halted 0 ms 0 KB -