답안 #110707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110707 2019-05-12T06:25:51 Z ckodser 케이크 (CEOI14_cake) C++14
0 / 100
2000 ms 2680 KB
#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll mod=1e9+7;
const ll maxn=5e5+500;
const ll inf=1e9+900;
const ll sq=10;


ll p[maxn];
ll n,a;

ll find_max(ll e){
    ll l=e;
    ll r=a;
    if(r<l){
	swap(l,r);
    }
    ll ans=0;
    for(ll i=l;i<=r;i++){
	ans=max(ans,p[i]);
    }
    return ans;
}
ll find_first_high(ll x,ll f){
    for(ll i=a;;i+=f){
	if(p[i]>x)return i;
    }
    return 0;
}
ll find_val(ll x){
    return p[x];
}
void update(ll a,ll b){
    for(ll i=1;i<=n;i++){
	if(p[i]==a){
	    p[i]=b;
	}
	else if(a<p[i] && p[i]<=b){
	    p[i]--;
	}
    }
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>a;
    p[0]=n+1;
    p[n+1]=n+2;
    for(ll i=1;i<=n;i++){
	cin>>p[i];
    }	
    ll q;
    cin>>q;
    for(ll i=0;i<q;i++){
	char c;
	cin>>c;
	if(c=='F'){
	    ll e;
	    cin>>e;
	    ll mi=find_max(e);
	    ll o;
	    if(e==a){
		cout<<0<<endl;
		continue;
	    }	
	    if(e<a){
		o=find_first_high(mi,1);
	    }else{
		o=find_first_high(mi,-1);
	    }
	    cout<<abs(o-e)-1<<endl;
	}else{
	    ll x,v;
	    cin>>x>>v;
	    update(p[x],n-v+1);
	}
    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2028 ms 496 KB Time limit exceeded
2 Execution timed out 2060 ms 384 KB Time limit exceeded
3 Execution timed out 2053 ms 512 KB Time limit exceeded
4 Execution timed out 2041 ms 512 KB Time limit exceeded
5 Execution timed out 2049 ms 512 KB Time limit exceeded
6 Execution timed out 2039 ms 512 KB Time limit exceeded
7 Execution timed out 2059 ms 512 KB Time limit exceeded
8 Execution timed out 2059 ms 512 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2041 ms 1716 KB Time limit exceeded
2 Execution timed out 2057 ms 1792 KB Time limit exceeded
3 Execution timed out 2059 ms 1868 KB Time limit exceeded
4 Incorrect 3 ms 384 KB Output isn't correct
5 Execution timed out 2053 ms 2652 KB Time limit exceeded
6 Execution timed out 2054 ms 2676 KB Time limit exceeded
7 Execution timed out 2056 ms 2680 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Incorrect 371 ms 612 KB Output isn't correct
2 Incorrect 521 ms 632 KB Output isn't correct
3 Execution timed out 2065 ms 1180 KB Time limit exceeded
4 Execution timed out 2057 ms 888 KB Time limit exceeded
5 Incorrect 728 ms 1016 KB Output isn't correct
6 Execution timed out 2056 ms 1156 KB Time limit exceeded
7 Execution timed out 2045 ms 888 KB Time limit exceeded
8 Execution timed out 2061 ms 1152 KB Time limit exceeded
9 Execution timed out 2069 ms 2680 KB Time limit exceeded
10 Execution timed out 2065 ms 1528 KB Time limit exceeded
11 Execution timed out 2063 ms 888 KB Time limit exceeded
12 Execution timed out 2050 ms 2144 KB Time limit exceeded
13 Execution timed out 2057 ms 2488 KB Time limit exceeded