Submission #367725

# Submission time Handle Problem Language Result Execution time Memory
367725 2021-02-18T06:23:45 Z arnold518 Zagrade (COI20_zagrade) C++14
71 / 100
1256 ms 6964 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N, Q;

map<pii, int> MM;

bool query(int l, int r)
{
	if(MM.find({l, r})!=MM.end()) return MM[{l, r}];
	printf("? %d %d\n", l, r);
	fflush(stdout);
	int t;
	scanf("%d", &t);
	MM[{l, r}]=t;
	return t;
}

char ans[MAXN+10];

int main()
{
	scanf("%d%d", &N, &Q);
	vector<int> V;

	for(int i=1; i<=N; i++)
	{
		if(V.empty()) V.push_back(i);
		else
		{
			int t=V.back();
			if(query(t, i))
			{
				ans[t]='(';
				ans[i]=')';
				V.pop_back();
			}
			else
			{
				V.push_back(i);
			}
		}
	}

	printf("! %s\n", ans+1);
	fflush(stdout);
}

Compilation message

zagrade.cpp: In function 'bool query(int, int)':
zagrade.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
zagrade.cpp: In function 'int main()':
zagrade.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |  scanf("%d%d", &N, &Q);
      |  ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 5 ms 364 KB Output is correct
3 Correct 13 ms 364 KB Output is correct
4 Correct 12 ms 364 KB Output is correct
5 Correct 12 ms 364 KB Output is correct
6 Correct 13 ms 364 KB Output is correct
7 Correct 12 ms 492 KB Output is correct
8 Correct 9 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 458 ms 3712 KB Output is correct
3 Correct 974 ms 6868 KB Output is correct
4 Correct 1208 ms 6832 KB Output is correct
5 Correct 1071 ms 6964 KB Output is correct
6 Correct 1256 ms 6764 KB Output is correct
7 Correct 1040 ms 6940 KB Output is correct
8 Correct 1069 ms 6848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -