Submission #65891

# Submission time Handle Problem Language Result Execution time Memory
65891 2018-08-09T05:35:07 Z ikura355 Cake (CEOI14_cake) C++14
0 / 100
2000 ms 3144 KB
#include<bits/stdc++.h>
using namespace std;

const int maxn = 250000 + 5;

int n,st,q;
int a[maxn];
int pos[maxn];

int main() {
	scanf("%d%d",&n,&st);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) pos[n-a[i]+1] = i;
	scanf("%d",&q);
	while(q--) {
		char type; scanf(" %c",&type);
		if(type=='F') {
			int x; scanf("%d",&x);
			if(x==st) printf("0\n");
			else if(x>st) {
				int mx = 0, l = st;
				for(int i=st+1;i<=x;i++) mx = max(mx, a[i]);
				for(int i=st-1;i>=1;i--) {
					if(a[i]>mx) break;
					l = i;
				}
				printf("%d\n",x-l);
			}
			else {
				int mx = 0, r = st;
				for(int i=st-1;i>=x;i--) mx = max(mx, a[i]);
				for(int i=st+1;i<=n;i++) {
					if(a[i]>mx) break;
					r = i;
				}
				printf("%d\n",r-x);
			}
		}
		else {
			int x,ra; scanf("%d%d",&x,&ra);
			for(int i=ra-1;i>=1;i--) a[pos[i]]++;
			a[x] = a[pos[ra]]+1;
			for(int i=15;i>=ra;i--) pos[i] = pos[i-1];
			pos[ra] = x;
//			for(int i=1;i<=n;i++) printf("%d ",pos[i]);
//			printf("\n");
		}
	}
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&st);
  ~~~~~^~~~~~~~~~~~~~~
cake.cpp:12:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
                        ~~~~~^~~~~~~~~~~~
cake.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);
  ~~~~~^~~~~~~~~
cake.cpp:16:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   char type; scanf(" %c",&type);
              ~~~~~^~~~~~~~~~~~~
cake.cpp:18:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int x; scanf("%d",&x);
           ~~~~~^~~~~~~~~
cake.cpp:40:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int x,ra; scanf("%d%d",&x,&ra);
              ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 194 ms 612 KB Output isn't correct
2 Correct 161 ms 612 KB Output is correct
3 Correct 164 ms 612 KB Output is correct
4 Correct 153 ms 636 KB Output is correct
5 Incorrect 180 ms 720 KB Output isn't correct
6 Incorrect 171 ms 780 KB Output isn't correct
7 Correct 206 ms 780 KB Output is correct
8 Correct 160 ms 780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2056 ms 1832 KB Time limit exceeded
2 Execution timed out 2045 ms 1856 KB Time limit exceeded
3 Execution timed out 2050 ms 2120 KB Time limit exceeded
4 Incorrect 3 ms 2120 KB Output isn't correct
5 Execution timed out 2074 ms 2992 KB Time limit exceeded
6 Execution timed out 2058 ms 2992 KB Time limit exceeded
7 Execution timed out 2054 ms 3092 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 3092 KB Output isn't correct
2 Correct 68 ms 3092 KB Output is correct
3 Correct 867 ms 3092 KB Output is correct
4 Incorrect 847 ms 3092 KB Output isn't correct
5 Incorrect 114 ms 3092 KB Output isn't correct
6 Execution timed out 2069 ms 3092 KB Time limit exceeded
7 Correct 495 ms 3092 KB Output is correct
8 Correct 155 ms 3092 KB Output is correct
9 Execution timed out 2065 ms 3092 KB Time limit exceeded
10 Incorrect 380 ms 3092 KB Output isn't correct
11 Execution timed out 2055 ms 3092 KB Time limit exceeded
12 Execution timed out 2061 ms 3092 KB Time limit exceeded
13 Execution timed out 2070 ms 3144 KB Time limit exceeded