Submission #1011456

# Submission time Handle Problem Language Result Execution time Memory
1011456 2024-06-30T13:56:29 Z vannnnnnnn Zagrade (COI20_zagrade) C++14
100 / 100
557 ms 1520 KB
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n, q;
	scanf("%d %d", &n, &q);
	char s[n+5];
	vector<int>v;
	s[1]='(';
	for(int i=1; i<=n; i++)
	{
		if(v.empty())
		{
			s[i]='(';
			v.push_back(i);
			continue;
		}
		printf("? %d %d\n", v.back(), i);
		fflush(stdout);
		int ans;
		scanf("%d", &ans);
		if(ans==1)
		{
			s[v.back()]='(';
			s[i]=')';
			v.pop_back();
		}
		else
		{
			v.push_back(i);
		}
	}
	for(int i=0; i<v.size()/2; i++)
	{
		s[v[i]]=')';
	}
	for(int i=v.size()/2; i<v.size(); i++)
	{
		s[v[i]]='(';
	}
	printf("! ");
	for(int i=1; i<=n; i++)
	{
		printf("%c", s[i]);
	}
	printf("\n");
	fflush(stdout);
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:34:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for(int i=0; i<v.size()/2; i++)
      |               ~^~~~~~~~~~~
zagrade.cpp:38:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int i=v.size()/2; i<v.size(); i++)
      |                        ~^~~~~~~~~
zagrade.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%d %d", &n, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~
zagrade.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%d", &ans);
      |   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 6 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 6 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 4 ms 440 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 5 ms 600 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 273 ms 344 KB Output is correct
3 Correct 533 ms 344 KB Output is correct
4 Correct 557 ms 344 KB Output is correct
5 Correct 518 ms 344 KB Output is correct
6 Correct 540 ms 344 KB Output is correct
7 Correct 510 ms 1252 KB Output is correct
8 Correct 546 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 527 ms 1520 KB Output is correct
3 Correct 536 ms 888 KB Output is correct
4 Correct 482 ms 1424 KB Output is correct
5 Correct 527 ms 1092 KB Output is correct
6 Correct 530 ms 1336 KB Output is correct
7 Correct 540 ms 1324 KB Output is correct
8 Correct 507 ms 508 KB Output is correct