QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#488711#9156. 百万富翁_LSA_91.00003 2061ms106128kbC++141.9kb2024-07-24 14:28:102024-07-24 14:28:10

Judging History

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

  • [2024-07-24 14:28:10]
  • 评测
  • 测评结果:91.00003
  • 用时:2061ms
  • 内存:106128kb
  • [2024-07-24 14:28:10]
  • 提交

answer

#include "richest.h"
using namespace std;
const int N = 1e6+10;
int cnt[N];
inline void clear(int n){
    for(int i=0;i<n;i++) cnt[i] = 0;
}
vector<int> work(vector<int> c,int k,bool flag=0){
    int n = c.size();
    int t = n/k,d = n%k;
    vector<int> siz;
    for(int i=1;i<=t;i++)
        siz.push_back(k);
    if(flag) siz.push_back(18),siz[0]--,siz[1]--,siz[2]--,siz[3]--;
    else for(int i=0;i<d;i++) siz[i]++;
    vector<int> a,b;
    int l = 0;
    vector<int> ll,rr;
    for(int i=0;i<t;i++){
        ll.push_back(a.size());
        int r = l+siz[i]-1;
        for(int j=l;j<=r;j++)
            for(int jj=j+1;jj<=r;jj++)
                a.push_back(c[j]),b.push_back(c[jj]);
        rr.push_back(a.size()-1);
        l += siz[i];
    }
    vector<int> rs = ask(a,b);
    vector<int> res;
    for(int x : c) cnt[x] = 0;
    for(int i=0;i<t;i++){
        for(int j=ll[i];j<=rr[i];j++){
            cnt[rs[j]]++;
            if(cnt[rs[j]] == siz[i]-1) res.push_back(rs[j]);
        }
    }
    return res;
}
int find(vector<int> c){
    int n = c.size();
    clear(1000000);
    vector<int> a,b,rs;
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++){
            a.push_back(c[i]);
            b.push_back(c[j]);
        }
    rs = ask(a,b);
    for(int x : rs){
        cnt[x]++;
        if(cnt[x] == n-1) return x;
    }
    return -1;
}
int richest(int n, int T, int S) {
    clear(n);
    if(n == 1000){
       vector<int> c;
       for(int i=0;i<n;i++) c.push_back(i);
       return find(c);
    }else{
        vector<int> c;
        for(int i=0;i<n;i++) c.push_back(i);
        c = work(c,2); c = work(c,2);
        c = work(c,2); c = work(c,2);
        c = work(c,3); c = work(c,6);
        c = work(c,19); return find(c);
    }
    return 1;
}
/*
g++ grader.cpp richest.cpp -o richest -O2 -std=c++14 -static
1000 1 499500 43243
1000000 20 2000000 34234
*/

详细


Pretests

Pretest #1:

score: 15
Accepted
time: 617ms
memory: 27084kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 76
Acceptable Answer
time: 2061ms
memory: 106128kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
708834003727782761
0.894118
11625001216319896173

result:

points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947


Final Tests

Test #1:

score: 15
Accepted
time: 627ms
memory: 27340kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 76
Acceptable Answer
time: 2044ms
memory: 105976kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
708834003727782761
0.894118
11625001216319896173

result:

points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947