QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#492473 | #9156. 百万富翁 | LinkWish# | 15 | 4781ms | 117712kb | C++14 | 1.8kb | 2024-07-26 12:38:56 | 2024-07-26 12:38:58 |
Judging History
answer
//Linkwish's code
#include<bits/stdc++.h>
#include "richest.h"
#define endl '\n'
#define si static inline
#define mp make_pair
#define fi first
#define se second
using namespace std;typedef long long ll;typedef __int128 li;
typedef pair<int,int> pii;typedef pair<ll,ll> pll;typedef const int ci;
typedef const ll cl;const int iinf=INT_MAX;const ll linf=LLONG_MAX;
template<typename T>si bool gmax(T &x,const T y){if(x<y)return x=y,1;return 0;}
template<typename T>si bool gmin(T &x,const T y){if(y<x)return x=y,1;return 0;}
int n;
namespace S1{
ci N=1005;
int tot[N];
si int solve(){
memset(tot,0,sizeof tot);
vector<int> a,b;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
a.push_back(i),b.push_back(j);
vector<int> res=ask(a,b);
for(int i=0;i<(int)res.size();i++)tot[res[i]]++;
for(int i=0;i<n;i++)if(tot[i]==n-1)return i;
return -1;
}
}
namespace S2{
si int solve(){
vector<int> cur;
for(int i=0;i<n;i++)cur.push_back(i);
mt19937 R(chrono::high_resolution_clock().now().time_since_epoch().count());
while(cur.size()>1){
//cerr<<"IN "<<cur.size()<<endl;
shuffle(cur.begin(),cur.end(),R);
vector<int> a,b;
for(int i=0;i<(int)cur.size()-1;i++)a.push_back(cur[i]),b.push_back(cur[i+1]);
vector<int> res=ask(a,b),tmp;
for(int i=0;i<(int)res.size();){
if(res[i]==cur[i]){
tmp.push_back(cur[i]);
int j=i+1;
while(j<(int)res.size()&&cur[j]==res[j])j++;
i=j;
}
else{
int j=i+1;
while(j<(int)cur.size()&&cur[j]==res[j-1])j++;
tmp.push_back(cur[j-1]);
i=j;
}
}
cur.swap(tmp);
}
return cur[0];
}
}
int richest(int N, int T, int S) {
n=N;
if(N<=1000)return S1::solve();
else return S2::solve();
return -1;
}
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 612ms
memory: 25436kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 1.00002
Acceptable Answer
time: 4721ms
memory: 117712kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 1 / 85, maxt = 18, maxs = 1923834 12073473151163982689 0.011765 673752051063430391
result:
points 0.011765 Partially correct Case 2, 1 / 85, maxt = 18, maxs = 1923834
Final Tests
Test #1:
score: 15
Accepted
time: 604ms
memory: 25272kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Wrong Answer
time: 4781ms
memory: 110244kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 0 / 85, maxt = 19, maxs = 1924128 3915989522437955771 0.000000 6906350380861515327
result:
points 0.0 Partially correct Case 2, 0 / 85, maxt = 19, maxs = 1924128