Submission #773515

# Submission time Handle Problem Language Result Execution time Memory
773515 2023-07-05T06:25:37 Z vjudge1 Zagrade (COI20_zagrade) C++17
100 / 100
859 ms 1200 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long lo; 

#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,a[li],k,flag,t;
int cev;
string s;
vector<int> v;
char b[li];

inline int in(){
	int x;
	cin>>x;
	return x;
}

int main(void){
	scanf("%d %d",&n,&t);
	FOR b[i]='_';
	stack<int> st;
	st.push(1);
	for(int i=1;i<n;i++){
		if(st.size()==0){st.push(i+1);continue;}
		printf("? %d %d\n",st.top(),i+1);
		fflush(stdout);
		scanf("%d",&a[i]);
		//~ cout<<st.top()<<" :: "<<i+1<<endl;
		if(a[i]==1){b[st.top()]='(';b[i+1]=')';st.pop();}
		else st.push(i+1);
	}
	int emp=0;
	FOR{
		if(b[i]=='_'){
			emp++;
		}
	}
	int tmp=0;
	FOR{
		if(b[i]=='_' && tmp<emp/2){tmp++;b[i]=')';}
		else if(b[i]=='_') b[i]='(';
	}
	printf("! ");
	FOR printf("%c",b[i]);
	printf("\n");
	fflush(stdout);
	return 0;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  scanf("%d %d",&n,&t);
      |  ~~~~~^~~~~~~~~~~~~~~
zagrade.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |   scanf("%d",&a[i]);
      |   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 11 ms 324 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 10 ms 320 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 9 ms 316 KB Output is correct
8 Correct 7 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 10 ms 320 KB Output is correct
3 Correct 10 ms 208 KB Output is correct
4 Correct 8 ms 320 KB Output is correct
5 Correct 7 ms 324 KB Output is correct
6 Correct 8 ms 308 KB Output is correct
7 Correct 10 ms 320 KB Output is correct
8 Correct 5 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 314 ms 776 KB Output is correct
3 Correct 609 ms 932 KB Output is correct
4 Correct 724 ms 740 KB Output is correct
5 Correct 720 ms 940 KB Output is correct
6 Correct 643 ms 816 KB Output is correct
7 Correct 859 ms 1096 KB Output is correct
8 Correct 668 ms 804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 835 ms 1200 KB Output is correct
3 Correct 701 ms 916 KB Output is correct
4 Correct 751 ms 928 KB Output is correct
5 Correct 814 ms 844 KB Output is correct
6 Correct 810 ms 868 KB Output is correct
7 Correct 783 ms 912 KB Output is correct
8 Correct 709 ms 784 KB Output is correct