This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define forf(i,a,b) for(int i = a; i<=b; i++)
#define forb(i,a,b) for(int i = a; i>=b; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
using namespace std;
int N,M;
int A[1001][3];
struct ST{
int id,time,acc;
bool operator<(const ST &r){
if(time ==r.time) return id<r.id;
return time<r.time;
}
};
vector<ST> dist[100001];
int isacc[100001];
int ans[10001];
int main(){
scanf("%d" ,&N);
forf(i,1,N){
scanf("%d %d %d" , &A[i][0],&A[i][1],&A[i][2]);
}
scanf("%d" , &M);
forf(i,1,M){
int t; scanf("%d" , &t);
isacc[t] = 1;
}
forf(i,1,N) dist[0].push_back({i,0,0});
forf(i,0,299){
int seg = i/100;
sort(all(dist[i]));
int cnt = 0;
forf(j,0,N-1){
if(j && dist[i][j-1].time == dist[i][j].time) cnt++;
else cnt = 0;
if(isacc[i] && dist[i][j].acc == 0) dist[i][j].acc = (j-cnt)%20;
if(dist[i][j].acc) dist[i+1].push_back({dist[i][j].id,dist[i][j].time+1,dist[i][j].acc-1});
else dist[i+1].push_back({dist[i][j].id,dist[i][j].time+A[dist[i][j].id][seg],0});
}
}
for(auto i : dist[300]){
ans[i.id] = i.time;
}
forf(i,1,N) printf("%d\n" , ans[i]);
}
Compilation message (stderr)
segway.cpp: In function 'int main()':
segway.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | scanf("%d" ,&N);
| ~~~~~^~~~~~~~~~
segway.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | scanf("%d %d %d" , &A[i][0],&A[i][1],&A[i][2]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
segway.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | scanf("%d" , &M);
| ~~~~~^~~~~~~~~~~
segway.cpp:26:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | int t; scanf("%d" , &t);
| ~~~~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |