QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#490878#9156. 百万富翁EternatisCompile Error//C++145.2kb2024-07-25 16:38:042024-07-25 16:38:05

Judging History

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

  • [2024-07-25 16:38:05]
  • 评测
  • [2024-07-25 16:38:04]
  • 提交

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();
}
/*
static int N, T, S, r, t, s;
static vector<int> W;
vector<int> ask(vector<int> i, vector<int> j) {
    ++t;
    if (t > T)
        throw string("Too many queries");
    if (i.size() != j.size())
        throw string("Invalid query: i and j must have the same size");
    int m = i.size();
    s += m;
    if (s > S)
        throw string("Too many total elements in queries");
    vector<int> res(m);
    for (int k = 0; k < m; k++) {
        if (i[k] < 0 || i[k] >= N || j[k] < 0 || j[k] >= N)
            throw string("Invalid query: index out of bounds");
        res[k] = W[i[k]] > W[j[k]] ? i[k] : j[k];
    }
    return res;
}

constexpr int Sub2_score = 85;

int main() {
    int R;
    cin >> N >> T >> S >> R;
    if (N <= 0 || T < 0 || S < 0 || R < 0) {
        cerr << "Invalid input for N, T, S or R" << endl;
        return 1;
    }
    mt19937_64 rng(R);
    W.resize(N);
    bool hasWrong = false;
    int maxt = 0, maxs = 0;
    for (int _ = 0; _ < 10; _++) {
        iota(W.begin(), W.end(), 0);
        shuffle(W.begin(), W.end(), rng);
        int answer = max_element(W.begin(), W.end()) - W.begin();
        try {
            r = -1; t = 0; s = 0;
            r = richest(N, T, S);
        	for(int i=0;i<N;i++)cout << W[i] << " ";
			puts("");
			cout << r << endl;
            if (r != answer)
                throw string("Wrong Answer");
            cout << r << ' ' << t << ' ' << s << " Correct (pretest)" << endl;
        } catch (const string& msg) {
            hasWrong = true;
            cout << r << ' ' << t << ' ' << s << ' ' << msg << endl;
        }
        maxt = max(maxt, t);
        maxs = max(maxs, s);
    }
    if (N == 1000 && T == 1 && S == 499500) {
        if (hasWrong) {
            cout << "Wrong Case 1, score: 0 / " << (100 - Sub2_score) << endl;
        } else {
            cout << "Correct (pretest) Case 1, score: " << (100 - Sub2_score) << " / " << (100 - Sub2_score) << endl;
        }
    } else if (N == 1000000 && T == 20 && S == 2000000) {
        if (hasWrong) {
            cout << "Wrong Case 2, score: 0 / " << Sub2_score << endl;
        } else {
            double ft = 1;
            if (maxt > 8)
                ft -= sqrt(maxt - 8) / 4;
            double gs = 1;
            if (maxs > 1099944) {
            	if (maxs < 1100044)
            		gs -= log10(maxs - 1099943) / 6;
            	else
            		gs -= 1.0 / 3 + pow(maxs - 1100043, 1.0 / 2) / 1500;
			}
            cout
                << (ft * gs >= 1 ? "Correct" : "Partially correct")
                << " (pretest) Case 2, score: "
                << to_string(int(Sub2_score * ft * gs))
                << " / " << Sub2_score;
        }
    } else {
        if (hasWrong) {
            cout << "Wrong" << endl;
        } else {
            cout << "Correct" << endl;
        }
    }
}
*/

Details

answer.code: In function ‘int richest(int, int, int)’:
answer.code:113:21: error: ‘solve2’ was not declared in this scope; did you mean ‘solve1’?
  113 |         else return solve2();
      |                     ^~~~~~
      |                     solve1