QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#527205#9156. 百万富翁sumi007#Compile Error//C++142.7kb2024-08-22 11:57:472024-08-22 11:57:48

Judging History

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

  • [2024-08-22 11:57:48]
  • 评测
  • [2024-08-22 11:57:47]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int vis[2077][2077],bel[1000007],p[1000005],B,len; 
set<int> s[10];
vector<int> vec[10];
int richest(int N, int T, int S) {
    if(N==1000 && T==1 && S==499500){
        vector<int> a,b,c;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                a.pb(i),b.pb(j);
            }
        }
        c = ask(a,b);
        for(int i=0;i<c.size();i++){
            int u = a[i],v = b[i],w = c[i];
            if(u == w) vis[u][v] = 1,vis[v][u] = 0;
            else vis[u][v] = 0,vis[v][u] = 1;
        }
        int ans = 0;
        for(int i=0;i<N;i++){
            int ck = 1;
            for(int j=0;j<N;j++){
                if(i==j) continue;
                if(!vis[i][j]) ck = 0;
            }
            if(ck == 1){
                ans = i;
                break;
            }
        }
        return ans;
    }else{
        srand(time(0));
        B = 100000;
        for(int i=0;i<10;i++){
            int l = i*B,r = l+B-1;
            for(int j=l;j<=r;j++) s[i].insert(j),bel[j] = i;
        }
        while(1){
            for(int i=0;i<10;i++) {
                vec[i].clear();
                for(int x:s[i]) vec[i].pb(x);
                random_shuffle(vec.begin(),vec.end());
            }
            vector<int> a,b,c;
            for(int i=0;i<10;i++){
                for(int j=0;j+1<vec[i].size();j++){
                    int u = vec[i][j],v = vec[i][j+1];
                    a.pb(u),b.pb(v);
                }
            } 
            c = ask(a,b);
            for(int i=0;i<c.size();i++){
                int u = a[i],v = b[i],w = c[i];
                if(u == w) s[bel[b[i]]].erase(b[i]);
                else s[bel[a[i]]].erase(a[i]);
            }
            int chk = 1;
            for(int i=0;i<10;i++) chk = chk&(s[i].size()==1);
            if(chk) break;
        }
        vector<int> f,a,b,c;
        for(int i=0;i<10;i++) f.pb(*s[i].begin());
        for(int i=0;i<10;i++){
            for(int j=i+1;j<10;j++){
                a.pb(f[i]),b.pb(f[j]);
            }
        }
        c = ask(a,b);
        for(int i=0;i<c.size();i++){
            int u = a[i],v = b[i],w = c[i];
            if(u == w) vis[bel[u]][bel[v]] = 1;
            else vis[bel[v]][bel[u]] = 1;
        }
        int ans = 0;
        for(int i=0;i<10;i++){
            int ck = 1;
            for(int j=0;j<10;j++){
                if(i==j) continue;
                if(!vis[i][j]) ck = 0;
            }
            if(ck == 1){
                ans = i;
                break;
            }
        }
        ans = f[i];
        return ans;
    }
}

Details

answer.code: In function ‘int richest(int, int, int)’:
answer.code:46:36: error: request for member ‘begin’ in ‘vec’, which is of non-class type ‘std::vector<int> [10]’
   46 |                 random_shuffle(vec.begin(),vec.end());
      |                                    ^~~~~
answer.code:46:48: error: request for member ‘end’ in ‘vec’, which is of non-class type ‘std::vector<int> [10]’
   46 |                 random_shuffle(vec.begin(),vec.end());
      |                                                ^~~
answer.code:90:17: error: ‘i’ was not declared in this scope
   90 |         ans = f[i];
      |                 ^