답안 #57965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57965 2018-07-16T14:47:44 Z MatheusLealV 케이크 (CEOI14_cake) C++17
0 / 100
2000 ms 41920 KB
#include <bits/stdc++.h>
#define N 250050
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;
 
int n, a, v[N], ans[N], q;
 
inline void process()
{
	int st = a, en = a, cnt = 1;
 
	ans[a] = 0;
 
	while(st > 1 or en < n)
	{
		//cout<<st<<" "<<en<<'\n';
 
		if( (v[st - 1] > v[en + 1] and en < n) or st <= 1)
		{
			ans[en + 1] = cnt;
 
			en ++;
		}
 
		else ans[st - 1] = cnt, st --;
 
		cnt ++;
	}
 
	//for(int i = 1; i <= n; i++) cout<<ans[i]<<" \n"[i == n];
}

pii val[N];

void update(int id, int e, int tempo)
{
	val[id] = {(n - e + 1), tempo};
}

void query()
{
	int st = a, en = a, cnt = 1;
 
	ans[a] = 0;
 
	while(st > 1 or en < n)
	{ 
		//cout<<st<<" "<<en<<"\n";
		if( (val[st - 1] > val[en + 1] and en < n) or st <= 1)
		{
			ans[en + 1] = cnt;
 
			en ++;
		}
 
		else ans[st - 1] = cnt, st --;
 
		cnt ++;
	}	
}

int esq[N], dir[N];
 
int main()
{
	//ios::sync_with_stdio(false); cin.tie(0);
 
	cin>>n>>a;
 
	for(int i = 1; i <= n; i++) cin>>v[i], val[i] = {v[i], 0};
 
	query();
 
	cin>>q;
 
	for(int i = 1; i <= q; i++)
	{
		char c; int a, b;
 
		cin>>c>>a;
 
		if(c == 'F')
		{
			query();

			cout<<ans[a]<<"\n";
		}
 
		else
		{
			cin>>b;
 
			update(a, b, i);
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 357 ms 5028 KB Output isn't correct
2 Correct 386 ms 9472 KB Output is correct
3 Incorrect 452 ms 13808 KB Output isn't correct
4 Correct 356 ms 18208 KB Output is correct
5 Incorrect 438 ms 22928 KB Output isn't correct
6 Incorrect 414 ms 27652 KB Output isn't correct
7 Incorrect 370 ms 32172 KB Output isn't correct
8 Correct 439 ms 37020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2056 ms 38344 KB Time limit exceeded
2 Execution timed out 2075 ms 38344 KB Time limit exceeded
3 Execution timed out 2067 ms 38520 KB Time limit exceeded
4 Incorrect 2 ms 38520 KB Output isn't correct
5 Execution timed out 2060 ms 40672 KB Time limit exceeded
6 Execution timed out 2064 ms 40748 KB Time limit exceeded
7 Execution timed out 2071 ms 40748 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Incorrect 301 ms 40748 KB Output isn't correct
2 Incorrect 745 ms 40748 KB Output isn't correct
3 Execution timed out 2043 ms 40748 KB Time limit exceeded
4 Execution timed out 2053 ms 40748 KB Time limit exceeded
5 Incorrect 645 ms 40748 KB Output isn't correct
6 Execution timed out 2072 ms 40748 KB Time limit exceeded
7 Execution timed out 2079 ms 40748 KB Time limit exceeded
8 Incorrect 803 ms 40748 KB Output isn't correct
9 Execution timed out 2063 ms 41752 KB Time limit exceeded
10 Execution timed out 2005 ms 41752 KB Time limit exceeded
11 Execution timed out 2078 ms 41752 KB Time limit exceeded
12 Execution timed out 2079 ms 41752 KB Time limit exceeded
13 Execution timed out 2068 ms 41920 KB Time limit exceeded