QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#414958#2929. Concert RehearsalTheSleepyDevilCompile Error//C++174.2kb2024-05-20 05:51:102024-05-20 05:51:12

Judging History

你现在查看的是最新测评结果

  • [2024-05-20 05:51:12]
  • 评测
  • [2024-05-20 05:51:10]
  • 提交

answer

/*
     Hell, 'til I reach Hell, I ain't scared
     Mama checkin' in my bedroom, I ain't there
                                                */
    #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;

    #define Major  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define TxtIO   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    #define read(a,n) for(int i = 0 ; i<n ; i++) cin>>a[i];
    #define write(a) for(auto x : a) cout<<x<<" ";
    #define int long long
    #define pb push_back
    #define all(a)  a.begin(),a.end()
    #define el "\n"

    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

    const int inf=4e18;

    int dx[]={1,0,-1,0,1,1,-1,-1};
    int dy[]={0,1,0,-1,1,-1,1,-1};

    const int mod=1e9+7;
    const int MAX =1e6+7;

   // ---------------------------Function----------------------------------//
    int n,p,k;
     vector<array<int,2>>arr;
     vector<int>pre;
     int check(int st,int kam){
        int sum=0;
        int cnt=kam/n,lft=kam%n;
        sum+=cnt*pre[n-1];
        if((st+lft-1<=0))return sum;
        sum+=pre[min(n-1,st+lft-1)]-(!st?0:pre[st-1]);

         int mnfo2=0;
         if((st+lft-1)>=n){
            mnfo2=n-(st+lft-1);
             sum+=pre[mnfo2];
         }
//        cout<<sum<<" "<<mnfo2<<el;
//        cout<<mnfo2<<el;


        return sum;
     }
     int vis[MAX],ans[MAX],base[MAX];
    void TestCake(){
        cin>>n>>p>>k;

        int sum=0;
        for(int i=0;i<n;i++){
            int x;cin>>x;
            arr.pb({x,i});sum+=x;
            pre.pb(sum);
        }
        if(n==1 || p%sum==0){
            cout<<(p/sum)*k<<el;return;
        }
        vector<array<int,2>>nxt;
        for(int i=0;i<n;i++){
            int l=1,r=1e9,z=1;
            while(l<=r){
                int mid=(l+r)/2;
                if(check(i,mid)>p){
                    z=mid;
                    r=mid-1;
                }
                else{
                    l=mid+1;
                }

            }
//        cout<<check(i,r)<<" "<<i<<" "<<r<<el;

           nxt.pb({(i+r)%n,r});
//           cout<<i<<" "<<(i+r)%n<<" "<<r<<el;
        }
        memset(vis,-1,sizeof vis);
        int st=0,cnt=0;
        vector<array<int,3>>here;
        while(vis[st]==-1){
            vis[st]=cnt;
            here.pb({st,nxt[st][0],nxt[st][1]});
            st=nxt[st][0];
            cnt++;
        }
         here.pb({st,nxt[st][0],nxt[st][1]});
//        cout<<cnt<<el;
//          for(auto x : here){
//             cout<<x[0]<<" "<<x[1]<<" "<<x[2]<<el;
//           }
        int tot=0;
        if(cnt>k){
            for(int i=0;i<here.size()-1&&k--;i++){
                 int l=here[i][0],r=here[i][1];
//                 cout<<l<<" "<<r<<el;
                 int m3aya=here[i][2],zyada=here[i][2]%n;
                 tot+=m3aya;
            }

        }
        else{
            k-=cnt;

//            cout<<k<<" "<<cnt<<el;
            int id=0;
            for(int i=0;i<here.size()-1;i++){
                if(here[i]==here.back()){id=i;break;}
            }
            int sz=(cnt-id);
            for(int i=0;i<here.size()-1;i++){
                 int m3aya=here[i][2],zyada=here[i][2]%n;
                 tot+=m3aya;

            }
            if(!sz)continue
            int have=(k/sz),ba2y=(k%sz);
            for(int i=id;i<here.size()-1;i++){
                 int m3aya=here[i][2],zyada=here[i][2]%n;
                 tot+=(have*m3aya);
            }
            for(int i=id;i<here.size()-1&&ba2y--;i++){
                 int m3aya=here[i][2];
                 tot+=(m3aya);
            }
        }
//        cout<<tot<<el;
        cout<<tot/n<<el;

    }
    //------------------------------Main---------------------------//
    signed main(){
        Major
        int T = 1;
//        cin >> T;
        while(T--){
            TestCake();
        //       cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
        }
        return 0;
    }

详细

answer.code: In function ‘void TestCake()’:
answer.code:122:20: error: continue statement not within a loop
  122 |             if(!sz)continue
      |                    ^~~~~~~~
answer.code:122:28: error: expected ‘;’ before ‘long’
  122 |             if(!sz)continue
      |                            ^
      |                            ;