QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#641830#9156. 百万富翁huazai676100 ✓2607ms95352kbC++171.5kb2024-10-15 01:10:082024-10-15 01:10:09

Judging History

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

  • [2024-10-15 01:10:09]
  • 评测
  • 测评结果:100
  • 用时:2607ms
  • 内存:95352kb
  • [2024-10-15 01:10:08]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<algorithm>
#include<random>
#include<vector>
#include "richest.h"

using namespace std;

typedef long long ll;

namespace
{
    const int N=1e6+10;
    int r[9]={1000000,500000,250000,125000,62496,20832,3472,183,1};
    vector<int> seq,a,b;
    bool vis[N];
    int st[N],tp;
    void init(int n)
    {
        seq.clear();
        for(int i=0;i<n;i++) seq.push_back(i);
        a.clear(),b.clear();
    }
    void clique(int l,int r)
    {
        for(int i=l;i<=r;i++)
            for(int j=i+1;j<=r;j++)
                a.push_back(seq[i]),b.push_back(seq[j]);
    }
    void Q()
    {
        vector<int> c=ask(a,b);
        for(int i=0;i<c.size();i++) vis[st[++tp]=a[i]^b[i]^c[i]]=true;
        vector<int> t;
        for(int i:seq) if(!vis[i]) t.push_back(i);
        swap(t,seq);
        while(tp) vis[st[tp--]]=false;
        a.clear(),b.clear();
    }
}

int richest(int n,int T,int S)
{
    init(n);
    if(n==1000)
    {
        clique(0,n-1);
        Q();
        return seq[0];
    }
    else
    {
        for(int i=0;i<8;i++)
        {
            int t=r[i]/r[i+1];
            int k=r[i]%r[i+1];
            int l=0;
            for(int j=0;j<(r[i+1]-k);j++)
            {
                clique(l,l+t-1);
                l+=t;
            }
            for(int j=0;j<k;j++)
            {
                clique(l,l+t);
                l+=t+1;
            }
            Q();
        }
        return seq[0];
    }
}

详细


Pretests

Pretest #1:

score: 15
Accepted
time: 624ms
memory: 25484kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2607ms
memory: 95352kb

input:

1000000 20 2000000 29091473

output:

Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
7610580723948932399
1.000000
1331569654267968081

result:

points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944


Final Tests

Test #1:

score: 15
Accepted
time: 622ms
memory: 24540kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2563ms
memory: 94252kb

input:

1000000 20 2000000 29091471

output:

Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
7610580723948932399
1.000000
1331569654267968081

result:

points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944