제출 #57914

#제출 시각아이디문제언어결과실행 시간메모리
57914MatheusLealVCake (CEOI14_cake)C++17
35 / 100
2088 ms3752 KiB
#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];
}

void update(int id, int e)
{
	vector<pii> val;

	int pos;

	for(int i = 1; i <= n; i++) if(i == id) pos = i;

	for(int i = 1; i <= n; i++)
	{
		if(i == id) continue;

		if(v[i] <= (n - e + 1) and v[i] > v[id]) v[i] --;
	}

	v[id] = (n - e + 1); 

	process();
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);

	cin>>n>>a;

	for(int i = 1; i <= n; i++) cin>>v[i];

	process();

	cin>>q;

	for(int i = 1; i <= q; i++)
	{
		char c; int a, b;

		cin>>c>>a;

		if(c == 'F') cout<<ans[a]<<'\n';

		else
		{
			cin>>b;

			update(a, b);
		}
	}
}

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

cake.cpp: In function 'void update(int, int)':
cake.cpp:39:6: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
  int pos;
      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...