Submission #353268

# Submission time Handle Problem Language Result Execution time Memory
353268 2021-01-21T07:09:54 Z arnold518 Nizovi (COI14_nizovi) C++14
0 / 100
241 ms 620 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 = 1000;
const int MAXM = 1e6;

int N, M;

int cmp(int x, int y)
{
	printf("cmp %d %d\n", x, y);
	fflush(stdout);
	int t;
	scanf("%d", &t);
	return t;
}

void rev(int l, int r)
{
	if(l>r) return;
	if(l==r) return;
	printf("reverse %d %d\n", l, r);
	fflush(stdout);
}

void end()
{
	printf("end\n");
	fflush(stdout);
}

pii A[MAXN+10];

int main()
{
	scanf("%d%d", &N, &M);

	int bef=N;
	for(int i=1; i<=N; i++)
	{
		int lo=N+1, hi=N+M+1;
		while(lo+1<hi)
		{
			int mid=lo+hi>>1;
			if(cmp(i, mid)==1) lo=mid;
			else hi=mid;
		}
		A[i]={bef, lo};
		bef=lo;
	}

	int s=1;
	for(int i=1; i<=N; i++)
	{
		rev(s, s+N-i);
		rev(s, A[i].second);
		rev(s, s+A[i].second-A[i].first);
		s+=A[i].second-A[i].first+1;
	}
	end();
}

Compilation message

nizovi.cpp: In function 'int main()':
nizovi.cpp:48:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |    int mid=lo+hi>>1;
      |            ~~^~~
nizovi.cpp: In function 'int cmp(int, int)':
nizovi.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
nizovi.cpp: In function 'int main()':
nizovi.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |  scanf("%d%d", &N, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Incorrect
2 Incorrect 2 ms 364 KB Incorrect
3 Incorrect 3 ms 364 KB Incorrect
4 Incorrect 39 ms 364 KB Incorrect
5 Incorrect 23 ms 380 KB Incorrect
6 Incorrect 57 ms 364 KB Incorrect
7 Incorrect 241 ms 620 KB Incorrect
8 Incorrect 178 ms 384 KB Incorrect
9 Incorrect 206 ms 492 KB Incorrect
10 Incorrect 151 ms 380 KB Total cost of reverse commands > 3 000 000