Submission #1041697

#TimeUsernameProblemLanguageResultExecution timeMemory
1041697vjudge1Segway (COI19_segway)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #define str string #define append push_back #define vi vector<int> #define int long long #define yes cout<<"YES"<<endl; #define no cout<<"NO"<<endl; #define endl '\n' #define all(ls) ls.begin(),ls.end() #define sorted(ls) sort(ls.begin(),ls.end()); #define reversed(ls) reverse(ls.begin(),ls.end()); #define print(n) for(auto i:n)cout<<i<<' ';cout<<endl; #define input(n,ls,m) vector<n>ls(m);for(int i=0;i<m;i++)cin>>ls[i]; #define len(s) s.size() #define ff first #define ss second int const N=2e5+100; int const LG=21; int mod=1e9+7; int mod1=998244353; int sum_(vector<int>ls){int s=0;for(auto i:ls)s+=i;return s;} int min(int a,int b){if (a>b){return b;}return a;} int max(int a,int b){if (a<b){return b;}return a;} //......................................tHe ReaL cOdE beGinS HerE......................................// void solve(){ int n; cin>>n; int ls[n+1][3]; memset(ls,0,sizeof(ls)); for(int i=1;i<=n;i++) cin>>ls[i][0]>>ls[i][1]>>ls[i][2]; // for(int i=1;i<=n;i++){cout<<ls[i][0]<<' '<<ls[i][1]<<' '<<ls[i][2]<<endl;} int dis[n+1]; int till[n+1]; int bst[n+1]; int ans[n+1],cnt[n+1],gv[n+1]; int m; cin>>m; int ac[301]; memset(ac,0,sizeof(ac)); for(int i=1;i<=m;i++){ int x; cin>>x; ac[x]=1; } for(int i=0;i<=n;i++){ dis[i]=0; till[i]=ls[i][0]; bst[i]=ans[i]=gv[i]=0; cnt[i]=0; } for(int t=1;t<=3000;t++){ int rnk[n+1]; vector<pair<int,int>>rnks; for(int i=1;i<=n;i++) rnks.append({dis[i],i}); sorted(rnks); reversed(rnks); rnk[rnks[0].ss]=0; for(int i=1;i<n;i++){ if(rnks[i].ff<rnks[i-1].ff){ rnk[rnks[i].ss]=i; } else rnk[rnks[i].ss]=rnk[rnks[i-1].ss]; } for(int i=1;i<=n;i++){ if(dis[i]>=300) continue; int spe; if(dis[i]+1<100) spe=ls[i][0]; else if(dis[i]+1<200) spe=ls[i][1]; else spe=ls[i][2]; if(bst[i]){ dis[i]++; if(dis[i]==300 and ans[i]<=0) ans[i]+=t; bst[i]--; if(!bst[i] and ac[dis[i]] and dis[i]!=gv[i]){ gv[i]=dis[i]; bst[i]=rnk[i]%20; cnt[i]++; } if(!bst[i]) till[i]=spe; continue; } till[i]--; if(till[i]<=0) {dis[i]++;till[i]=spe;} if(dis[i]==300 and ans[i]<=0) ans[i]+=t; if(ac[dis[i]] and dis[i]!=gv[i]){ gv[i]=dis[i]; bst[i]=rnk[i]%20; // if(i==2) cout<<rnk[i]%20<<' '<<dis[i]<<' '<<t<<endl; cnt[i]++; } if(dis[i]==300 and ans[i]<=0) ans[i]+=t; } } for(int i=1;i<=n;i++) cout<<ans[i]<<endl; } signed main(){ swap(mod,mod1); ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t=1; // cin>>t; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...