Submission #164452

# Submission time Handle Problem Language Result Execution time Memory
164452 2019-11-20T17:11:01 Z Lawliet Cake (CEOI14_cake) C++14
0 / 100
2000 ms 5580 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250010;
const int INF = 1000000010;

int n, p, q;

int v[MAXN];
int ans[MAXN];

void rebuild()
{
	int L = p - 1;
	int R = p + 1;
	int curTime = 0;

	ans[ p ] = curTime++;

	while( L != 0 || R != n + 1 )
	{
		if( v[ L ] < v[ R ] ) ans[ L-- ] = curTime++;
		else ans[ R++ ] = curTime++;
	}
}

int main()
{
	scanf("%d %d",&n,&p);

	v[ 0 ] = v[ n + 1 ] = INF;

	for(int i = 1 ; i <= n ; i++)
		scanf("%d",&v[i]);

	rebuild();

	scanf("%d",&q);

	for(int i = 1 ; i <= q ; i++)
	{
		char a;
		int pos;
		scanf(" %c %d",&a,&pos);

		if( a == 'F' ) printf("%d\n",ans[ pos ]);
		if( a == 'E' )
		{
			int newD;
			scanf("%d",&newD);

			for(int i = 1 ; i <= n ; i++)
				if( v[pos] < v[i] && v[i] <= newD ) v[ i ]--;

			v[ pos ] = n - newD + 1;
			
			rebuild();
		}
	}
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&p);
  ~~~~~^~~~~~~~~~~~~~~
cake.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&v[i]);
   ~~~~~^~~~~~~~~~~~
cake.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);
  ~~~~~^~~~~~~~~
cake.cpp:45:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c %d",&a,&pos);
   ~~~~~^~~~~~~~~~~~~~~~~~
cake.cpp:51:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&newD);
    ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 1308 KB Time limit exceeded
2 Execution timed out 2068 ms 1500 KB Time limit exceeded
3 Execution timed out 2039 ms 1364 KB Time limit exceeded
4 Execution timed out 2051 ms 1364 KB Time limit exceeded
5 Execution timed out 2025 ms 1204 KB Time limit exceeded
6 Execution timed out 2012 ms 1088 KB Time limit exceeded
7 Execution timed out 2041 ms 1084 KB Time limit exceeded
8 Execution timed out 2029 ms 1212 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 3096 KB Output isn't correct
2 Incorrect 65 ms 2956 KB Output isn't correct
3 Incorrect 62 ms 2936 KB Output isn't correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Incorrect 159 ms 5580 KB Output isn't correct
6 Incorrect 146 ms 5368 KB Output isn't correct
7 Incorrect 107 ms 5240 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 393 ms 944 KB Output isn't correct
2 Incorrect 586 ms 948 KB Output isn't correct
3 Execution timed out 2011 ms 1456 KB Time limit exceeded
4 Execution timed out 2047 ms 1804 KB Time limit exceeded
5 Incorrect 791 ms 2040 KB Output isn't correct
6 Execution timed out 2033 ms 1680 KB Time limit exceeded
7 Execution timed out 2013 ms 1660 KB Time limit exceeded
8 Execution timed out 2036 ms 1916 KB Time limit exceeded
9 Execution timed out 2081 ms 4128 KB Time limit exceeded
10 Execution timed out 2061 ms 4348 KB Time limit exceeded
11 Execution timed out 2059 ms 1412 KB Time limit exceeded
12 Execution timed out 2063 ms 3484 KB Time limit exceeded
13 Execution timed out 2061 ms 4268 KB Time limit exceeded