답안 #1041700

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041700 2024-08-02T07:12:19 Z vjudge1 Segway (COI19_segway) C++17
40 / 100
1000 ms 604 KB
#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<=15000;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]) till[i]=spe;
                if(!bst[i] and ac[dis[i]] and dis[i]!=gv[i]){
                    gv[i]=dis[i];
                    bst[i]=rnk[i]%20;
                    cnt[i]++;
                }
                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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 61 ms 348 KB Output is correct
3 Correct 326 ms 344 KB Output is correct
4 Execution timed out 1042 ms 604 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 9 ms 456 KB Output is correct
6 Correct 12 ms 456 KB Output is correct
7 Correct 24 ms 464 KB Output is correct
8 Correct 56 ms 348 KB Output is correct
9 Correct 66 ms 348 KB Output is correct
10 Correct 98 ms 344 KB Output is correct
11 Correct 63 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 61 ms 348 KB Output is correct
3 Correct 326 ms 344 KB Output is correct
4 Execution timed out 1042 ms 604 KB Time limit exceeded
5 Halted 0 ms 0 KB -