QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#516960#5207. Interactive Factorial GuessingParsaCompile Error//C++142.0kb2024-08-13 01:43:512024-08-13 01:43:51

Judging History

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

  • [2024-08-13 01:43:51]
  • 评测
  • [2024-08-13 01:43:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair <int, int>, null_type,less<pair <int, int>>, rb_tree_tag,tree_order_statistics_node_update>

#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define fr first
#define sc second

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;


const int MAXN = 5893, MAXM = 2e4 + 10, MOD = 998244353, MOD1 = 1e9 + 9, SQ = 350;
const long long INF = 1e9 + 11;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int fact[MAXN][MAXM];


int go[MAXM][10], tsz, query[MAXM];
vector <int> ids[MAXM];

int Build(vector <int> cand) {
	int root = ++tsz;
	ids[root] = cand;
	if (cand.size() <= 1) return root;
	int best = -1, now = cand.size() + 1;
	for (int j = 0; j < MAXM; j++) {
		vector <int> cnt(10, 0);
		for (int i: cand) {
			cnt[fact[i][j]]++;
		}
		int mx = 0;
		for (int i = 0; i < 10; i++) {
			mx = max(mx, cnt[i]);
		}
		if (mx < now) {
			now = mx;
			best = j;
		}
	}
	query[root] = best;
	vector <vector <int>> child(10, vector <int>());
	for (int i: cand) {
		child[fact[i][best]].pb(i);
	}
	for (int i = 0; i < 10; i++) {
		go[root][i] = Build(child[i]);
	}
	return root;
}

int main() {
    fact[1][0] = 1;
	for (int i = 2; i < MAXN; i++) {
		int carry = 0;
		for (int j = 0; j < MAXM; j++) {
			carry += i * fact[i - 1][j];
			fact[i][j] = carry % 10;
			carry /= 10;
		}
	}
    vector <int> cand;
	for (int i = 1; i < MAXN; i++) cand.pb(i);
	int root = Build(cand);
	int tt;
    scanf("%d", &t);
	while (tt--) {
        int curr = root;
		while (ids[curr].size() != 1){
		    printf("? %d\n", query[curr]);
			fflush(stdout);
			int cif;
			scanf("%d", &cif);
			curr = go[curr][cif];
		}
        printf("! %d\n", ids[curr][0]);
		fflush(stdout);
        string s;
		scanf("%s", s);
	}
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:73:18: error: ‘t’ was not declared in this scope; did you mean ‘tt’?
   73 |     scanf("%d", &t);
      |                  ^
      |                  tt
answer.code:86:25: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} [-Wformat=]
   86 |                 scanf("%s", s);
      |                        ~^
      |                         |
      |                         char*
answer.code:80:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   80 |                         scanf("%d", &cif);
      |                         ~~~~~^~~~~~~~~~~~
answer.code:86:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   86 |                 scanf("%s", s);
      |                 ~~~~~^~~~~~~~~