Submission #25955

# Submission time Handle Problem Language Result Execution time Memory
25955 2017-06-25T08:04:11 Z 서규호(#1088) Cake (CEOI14_cake) C++14
20 / 100
2000 ms 5592 KB
#include <bits/stdc++.h>

#define lld long long
#define pp pair<int,int>
#define pb push_back
#define MOD 1000000007
#define left lleft
#define right rright
#define INF 2000000000
#define Linf 1000000000000000000LL
#define next nnext
#define minus mminus

using namespace std;

int N,M,Q,K;
int a[250002],ans[250002];
vector<int> X;

void process(){
	int l,r;
	l = M; r = M;
	while(r-l != N-1){
		if(l == 1 || (r != N && a[r+1] < a[l-1])){
			r++;
			ans[r] = r-l;
		}else{
			l--;
			ans[l] = r-l;
		}
	}
}

int main(){
	scanf("%d %d",&N,&M);
	for(int i=1; i<=N; i++){
		scanf("%d",&a[i]);
		X.pb(a[i]);
	}
	sort(X.begin(),X.end());
	for(int i=1; i<=N; i++){
		a[i] = lower_bound(X.begin(),X.end(),a[i])-X.begin()+1;
	}
	process();
	scanf("%d",&Q);
	for(int i=1; i<=Q; i++){
		int x,y,t,t2;
		char op[3];
		scanf("%s %d",op,&x);
		if(op[0] == 'F'){
			printf("%d\n",ans[x]);
		}else{
			scanf("%d",&y);
			y = N-y+1;
			if(x == M) continue;
			for(int j=1; j<=N; j++){
				if(a[x] < a[j] && a[j] <= y){
					a[j]--;
				}
			}
			a[x] = y;
			process();
		}
	}

	return 0;
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:47:11: warning: unused variable 't' [-Wunused-variable]
   int x,y,t,t2;
           ^
cake.cpp:47:13: warning: unused variable 't2' [-Wunused-variable]
   int x,y,t,t2;
             ^
cake.cpp:35:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&N,&M);
                      ^
cake.cpp:37:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
                    ^
cake.cpp:45:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&Q);
                ^
cake.cpp:49:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s %d",op,&x);
                       ^
cake.cpp:53:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&y);
                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3972 KB Output is correct
2 Correct 0 ms 3972 KB Output is correct
3 Correct 0 ms 3972 KB Output is correct
4 Incorrect 16 ms 3972 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2000 ms 4112 KB Execution timed out
2 Execution timed out 2000 ms 4112 KB Execution timed out
3 Execution timed out 2000 ms 4112 KB Execution timed out
4 Execution timed out 2000 ms 4112 KB Execution timed out
5 Execution timed out 2000 ms 4244 KB Execution timed out
6 Execution timed out 2000 ms 4244 KB Execution timed out
7 Execution timed out 2000 ms 4244 KB Execution timed out
8 Execution timed out 2000 ms 4244 KB Execution timed out
# Verdict Execution time Memory Grader output
1 Correct 149 ms 4824 KB Output is correct
2 Correct 89 ms 4824 KB Output is correct
3 Correct 99 ms 4824 KB Output is correct
4 Correct 0 ms 3972 KB Output is correct
5 Correct 256 ms 5592 KB Output is correct
6 Correct 253 ms 5592 KB Output is correct
7 Correct 186 ms 5592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 489 ms 3972 KB Output isn't correct
2 Incorrect 809 ms 4112 KB Output isn't correct
3 Execution timed out 2000 ms 4440 KB Execution timed out
4 Execution timed out 2000 ms 4440 KB Execution timed out
5 Incorrect 1036 ms 3972 KB Output isn't correct
6 Execution timed out 2000 ms 4824 KB Execution timed out
7 Execution timed out 2000 ms 4112 KB Execution timed out
8 Execution timed out 2000 ms 4824 KB Execution timed out
9 Execution timed out 2000 ms 5592 KB Execution timed out
10 Execution timed out 2000 ms 3972 KB Execution timed out
11 Execution timed out 2000 ms 4244 KB Execution timed out
12 Execution timed out 2000 ms 5592 KB Execution timed out
13 Execution timed out 2000 ms 5592 KB Execution timed out