QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#791210#9156. 百万富翁Cmr56.000005 2044ms90772kbC++143.1kb2024-11-28 17:28:412024-11-28 17:28:43

Judging History

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

  • [2024-11-28 17:28:43]
  • 评测
  • 测评结果:56.000005
  • 用时:2044ms
  • 内存:90772kb
  • [2024-11-28 17:28:41]
  • 提交

answer

#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
std::vector <int> ask(std::vector <int> a, std::vector <int> b);
int rfs[1005][1005];
void Div2(vector < int >& now) {
    vector < int > a , b , c;
        int sig = -1;
        if(now.size() & 1) {
            sig = now.back();
        }
        for(int i = 0 ; i + 1 < now.size() ; i += 2) {
            a.push_back(now[i]);
            b.push_back(now[i + 1]);
        }c = ask(a , b);
        if(~sig) c.push_back(sig);
    now = c;
}
void Div(vector < int > &now , int p) {
    vector < int > a , b , c , sig , nxt;
        while(now.size() % p) {
            sig.push_back(now.back()); now.pop_back();
        }
        for(int i = 0 ; i + p - 1 < now.size() ; i += p) {
            for(int j = i ; j < i + p ; j++) {
                for(int k = j + 1 ; k < i + p; k++) {
                    a.push_back(now[j]);
                    b.push_back(now[k]);
                }
            }
        }c = ask(a , b);
        int id = 0;
        for(int i = 0 ; i + p - 1 < now.size() ; i += p) {
            int ans = 0 , cnt = 0;
            map < int , int > mp;
            for(int j = i ; j < i + p ; j++) {
                for(int k = j + 1 , u ; k < i + p ; k++) {
                    u = c[id++];
                    mp[u]++;
                    if(mp[u] > cnt) {
                        cnt = mp[u];
                        ans = u;
                    }
                }
            }
            nxt.push_back(ans);
        }
    now = nxt;
    while(sig.size()) now.push_back(sig.back()) , sig.pop_back();
}
int richest(int N , int T , int S) { 
    int cnt = 0;
    if(N == 1000) {
        vector < int > a , b , c;
       
        for(int i = 0 ; i < N ; i++) {
            for(int j = i + 1 ; j < N ; j++) {
                a.push_back(i);
                b.push_back(j);
                rfs[i][j] = cnt++;
            }
        }c = ask(a , b);
        int ans = 0;
        for(int i = 1 ; i < N ; i++) {
            int u = i , v = ans;
            if(u > v) swap(u , v);
            ans = c[rfs[u][v]];
        }return ans;
    }   
    vector < int > now;
    now.resize(N , 0);
    for(int i = 0 ; i < N ; i++) now[i] = i;
    for(int i = 1 ; i <= 5 ; i++) {
        Div2(now);
    }
    for(int i = 1 ; i <= 2 ; i++) {
        Div(now , 10);
    }vector < int > a , b , c;
    cerr << now.size() << endl;
    for(int i = 0 ; i < now.size() ; i++) {
        for(int j = i + 1 ; j < now.size() ; j++) {
            // if(now[i] > now[j]) swap(now[i] , now[j])
            a.push_back(now[i]);
            b.push_back(now[j]);
            rfs[i][j] = cnt++;
        }
    }c = ask(a , b);
    int ans = now.size() - 1;
    for(int i = 0 ; i < now.size() - 1 ; i++) {
        int u = i , v = ans;
        if(u > v) swap(u , v);
        ans = c[rfs[u][v]] == now[u] ? u : v;
    }
    return now[ans];
}
/*
g++ grader.cpp 2.cpp -o 2 -O2 -std=c++14 -static
1000000
1 500000 500000
3 125000 125000

333334 666666
666666
111112 222224
888888
37038   
962962
115569
*/

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 604ms
memory: 29436kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 41
Acceptable Answer
time: 2044ms
memory: 89988kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 41 / 85, maxt = 8, maxs = 1173501
1020971199171329455
0.482353
4036204156342914593

result:

points 0.482353 Partially correct Case 2, 41 / 85, maxt = 8, maxs = 1173501


Final Tests

Test #1:

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

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 41
Acceptable Answer
time: 2014ms
memory: 90772kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 41 / 85, maxt = 8, maxs = 1173501
1020971199171329455
0.482353
4036204156342914593

result:

points 0.482353 Partially correct Case 2, 41 / 85, maxt = 8, maxs = 1173501