QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#544089#9156. 百万富翁jay_jayjay#81.999975 2157ms86792kbC++172.6kb2024-09-02 04:51:402024-09-02 04:51:41

Judging History

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

  • [2024-09-02 04:51:41]
  • 评测
  • 测评结果:81.999975
  • 用时:2157ms
  • 内存:86792kb
  • [2024-09-02 04:51:40]
  • 提交

answer

#include "richest.h"

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()

int richest(int N, int T, int S) {
        if(N<=1000) {
                vector<int> a,b;
                vector<int> occ(N);
                for(int i=0;i<N;i++)for(int j=i+1;j<N;j++) a.push_back(i),b.push_back(j);
                auto res = ask(a,b);
                for(auto x:res)occ[x]++;
                return max_element(all(occ)) - occ.begin();
        }
        //vector<int> p {2, 2, 2, 2, 5, 10, 20, (int)1e9};
        //vector<int> p {2, 2, 2, 3, 11, 14, 81, (int)1e9};
        vector<int> p{2, 2, 2, 2, 3, 6, 19, (int)1e9};
        vector<int> pos(N);
        for(int i=0;i<N;i++)pos[i]=i;

        for(auto l : p) {
                for(auto x:pos)assert(0<=x&&x<N);
                int n = pos.size();
                l=min(l, n);
                //printf("%d %d\n",n,l);
                if(l==1)break;

                vector<int> a,b;
                for(int z=0;z<n/l;z++) {
                        int i=z*l;
                        for(int j=0;j<l;j++)
                                for(int k=j+1;k<l;k++)
                                        a.push_back(pos[i+j]),b.push_back(pos[i+k]);
                }
                int l2=n%l;
                if(l2>1){
                        int i=n/l*l;
                        for(int j=0;j<l2;j++)
                        for(int k=j+1;k<l2;k++)
                        a.push_back(pos[i+j]),b.push_back(pos[i+k]);
                }


                auto res = ask(a,b);
                vector<int> nx;
                //for(int i=n/l*l;i<n;i++) nx.push_back(pos[i]);

                for(int i=0;i<n/l;i++) {
                        map<int,int> occ;
                        for(int j=0;j<l*(l-1)/2;j++)
                                occ[res[i*l*(l-1)/2+j]]++;
                        int mx=-1;
                        for(auto [x,y]:occ)if(y==l-1)mx=x;
                        assert(mx!=-1);
                        nx.push_back(mx);
                }
                if(l2>1){
                        map<int,int> occ;
                        for(int j=0;j<l2*(l2-1)/2;j++)
                        occ[res[n/l*l*(l-1)/2+j]]++;
                        int mx=-1;
                        for(auto [x,y]:occ)if(y==l2-1)mx=x;
                        assert(mx!=-1);
                        nx.push_back(mx);
                }
                if(l2==1)nx.push_back(pos[n-1]);
                swap(pos,nx);
        }

//for(auto x:pos)printf("%d ",x);
        //printf("return %d\n",pos[0]);
        return pos[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 607ms
memory: 22052kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 67
Acceptable Answer
time: 2156ms
memory: 86792kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960
2586970244946203279
0.788235
12006835993993373281

result:

points 0.788235 Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960


Final Tests

Test #1:

score: 15
Accepted
time: 609ms
memory: 23108kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 67
Acceptable Answer
time: 2157ms
memory: 86664kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960
2586970244946203279
0.788235
12006835993993373281

result:

points 0.788235 Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960