QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#490884 | #9156. 百万富翁 | Eternatis | 15 | 633ms | 35544kb | C++14 | 2.4kb | 2024-07-25 16:38:37 | 2024-07-25 16:38:37 |
Judging History
answer
//¸¡ÓÎÖ®ÈË Ò²ÕõÔú²»ÒÑÖ´×Å´æÔÚÏÂÈ¥
#include<bits/stdc++.h>
//#include "richest.h"
using namespace std;
#define NN 1000010
#define db long double
#define pii pair<int,int>
#define st first
#define ed second
#define mkp make_pair
#define pb push_back
#define eps 1e-9
#define mod 998244353
#define mod2 1000000007
#define bs 13131
#define bs2 131
#define INF 0x3f3f3f3f3f3f3f3f
#define il inline
#define vi vector<int>
#define ins insert
#define umap unordered_map
#define uset unordered_set
#define R(x) x.begin(),x.end()
#define B(x) x.begin()
#define E(x) x.end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int>
il int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
int n,m,q,k;
struct edge{
int y,nxt;
}e[NN];
int head[NN],tot,now[NN];
il void add(int x,int y){
e[++tot]={y,head[x]};
head[x]=tot;
}
vi ask(vi a,vi b);
int vis[NN];
il void reset(int n){
tot=0;
for(int i=0;i<n;i++)head[i]=now[i]=vis[i]=0;
}
il int get(vi a){
int p=a[0];
while(head[p]){
for(int &i=now[p];i;i=e[i].nxt){
p=e[i].y;
i=e[i].nxt;
break;
}
if(!p)break;
}
return p;
}
il int solve1(){
reset(n);
vi a,b;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
a.pb(i),b.pb(j);
vi op=ask(a,b);
for(int i=0;i<op.size();i++){
int A=a[i],B=b[i];
if(op[i]==A)add(B,A);
else add(A,B);
}
for(int i=0;i<n;i++)now[i]=head[i];
a.clear();
for(int i=0;i<n;i++)a.pb(i);
return get(a);
}
queue<int> Q[9];
//il int solve2(){
// for(int i=500000;i>=1;i--)Q[1].push(2);
// for(int i=250000;i>=1;i--)Q[2].push(2);
// for(int i=125000;i>=1;i--)Q[3].push(2);
// for(int i=67500;i>=1;i--)Q[4].push(2);
// for(int i=20832;i>=1;i--)Q[5].push(3);Q[5].push(4);
// for(int i=3471;i>=1;i--)Q[6].push(6);Q[6].push(7);
// for(int i=168;i>=1;i--)Q[7].push(19);
// for(int i=14;i>=1;i--)Q[7].push(20);
// Q[8].push(182);
// vector<int> x,y;
// for(int i=0;i<1000000;i++)x.pb(i);
// int sz=1000000;
// for(int k=1;k<=8;k++){
// reset(sz);
// int l=0;
// while(!Q[k].empty()){
// int r=l+Q[k].front()-1;
// Q[k].pop();
//
// }
// }
//}
int richest(int nn,int ttt,int sss){
n=nn;
if(n<=1000)return solve1();
// else return solve2();
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 626ms
memory: 35544kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Memory Limit Exceeded
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 15
Accepted
time: 633ms
memory: 35436kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Memory Limit Exceeded
input:
1000000 20 2000000 29091471
output:
Unauthorized output