제출 #65869

#제출 시각아이디문제언어결과실행 시간메모리
65869ikura355케이크 (CEOI14_cake)C++14
0 / 100
2084 ms33248 KiB
#include<bits/stdc++.h>
using namespace std;

const int maxn = 250000 + 5;

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

int main() {
	scanf("%d%d",&n,&st);
	for(int i=1;i<=n;i++) scanf("%d",&a[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;
				for(int i=st;i<=x;i++) mx = max(mx, a[i]);
				for(int i=st;i>=1;i--) {
					if(a[i]>mx) break;
					l = i;
				}
				printf("%d\n",x-l);
			}
			else {
				int mx = 0, r;
				for(int i=st;i>=x;i--) mx = max(mx, a[i]);
				for(int i=st;i<=n;i++) {
					if(a[i]>mx) break;
					r = i;
				}
				printf("%d\n",r-x);
			}
		}
		else {
			int x,val; scanf("%d%d",&x,&val);
			int tmp = a[x];
			for(int i=1;i<=n;i++) if(val<=a[i] && a[i]<=tmp) a[i]--;
			a[x] = n-val+1;
		}
	}
}

컴파일 시 표준 에러 (stderr) 메시지

cake.cpp: In function 'int main()':
cake.cpp:10: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:11: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:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);
  ~~~~~^~~~~~~~~
cake.cpp:14: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:16: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:38:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int x,val; scanf("%d%d",&x,&val);
               ~~~~~^~~~~~~~~~~~~~~~
cake.cpp:34:11: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
     printf("%d\n",r-x);
     ~~~~~~^~~~~~~~~~~~
cake.cpp:25:11: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
     printf("%d\n",x-l);
     ~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...