Submission #243502

#TimeUsernameProblemLanguageResultExecution timeMemory
243502vanicSegway (COI19_segway)C++14
100 / 100
279 ms32760 KiB
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>

using namespace std;

const int maxn=2e4+5, maxp=305;

int v[maxn][3];
vector < int > q[50*maxp];
int loc[maxn];
int sad[maxp];
int acel[maxn];
bitset < maxp > boost;
int sol[maxn];
vector < int > ind;
int pref[maxp];

int main(){
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%d%d%d", &v[i][0], &v[i][1], &v[i][2]);
		q[v[i][0]].push_back(i);
	}
	int m;
	scanf("%d", &m);
	int a;
	for(int i=0; i<m; i++){
		scanf("%d", &a);
		boost[a]=1;
	}
	for(int i=0; i<maxp; i++){
		pref[i]=n;
	}
	int p;
	for(int i=0; i<50*maxp; i++){
		while(!q[i].empty()){
			p=q[i].back();
			q[i].pop_back();
			ind.push_back(p);
			pref[loc[p]]--;
			loc[p]++;
			sad[loc[p]]++;
			if(loc[p]==300){
				sol[p]=i;
				continue;
			}
			if(!acel[p] && boost[loc[p]]){
				acel[p]=(n-pref[loc[p]-1]-sad[loc[p]])%20;
			}
			if(acel[p]){
				acel[p]--;
				q[i+1].push_back(p);
			}
			else{
				q[i+v[p][loc[p]/100]].push_back(p);
			}
		}
		while(!ind.empty()){
			sad[loc[ind.back()]]--;
			ind.pop_back();
		}
	}
	for(int i=0; i<n; i++){
		printf("%d\n", sol[i]);
	}
	return 0;
}

Compilation message (stderr)

segway.cpp: In function 'int main()':
segway.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
segway.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &v[i][0], &v[i][1], &v[i][2]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
segway.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &m);
  ~~~~~^~~~~~~~~~
segway.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...