70,6个点TLE
查看原帖
70,6个点TLE
301765
ElfOfEra楼主2022/3/24 17:10

有点乱

// Problem: P2058 [NOIP2016 普及组] 海港
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P2058
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<iostream>
#include<queue>
using namespace std;
int main(){
    int n;
    cin>>n;
    queue<int> boat,pn,t;
    for(int i=1;i<=n;i++){
        int q,w;
        cin>>q>>w;
        t.push(q);pn.push(w);
        while(t.back()-t.front()>=86400){
            for(int p=0;p<pn.front();p++){
                boat.pop();
            }
            t.pop();pn.pop();
        }
        for(int b=1;b<=pn.back();b++){
            int l;
            cin>>l;
            boat.push(l);
        }
        queue<int> bc,co;
        bc=boat;
        int bcs=bc.size();
        for(int o=0;o<bcs;o++){
            queue<int> cp;
            cp=co;
            int cps=cp.size(),an=0;
            for(int l=0;l<cps;l++){
                if(bc.front()==cp.front()) an++;
                cp.pop();
            }
            if(an==0) co.push(bc.front());
            bc.pop();
        }
        cout<<co.size()<<endl;
    }
    return 0;
}

难者不会?

2022/3/24 17:10
加载中...