QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#488713 | #9156. 百万富翁 | _LSA_ | 100 ✓ | 2049ms | 106052kb | C++14 | 1.9kb | 2024-07-24 14:29:28 | 2024-07-24 14:29:30 |
Judging History
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]--,t++;
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,1); 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: 27340kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2049ms
memory: 106052kb
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: 27972kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2037ms
memory: 105968kb
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