QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#496991#4218. Hidden GraphPZhengCompile Error//C++141.4kb2024-07-28 17:46:132024-07-28 17:46:13

Judging History

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

  • [2024-07-28 17:46:13]
  • 评测
  • [2024-07-28 17:46:13]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <random>
#include <chrono>

using namespace std;
using i64 = long long;
using u64 = unsigned long long;

mt19937_64 rng {std::chrono::steady_clock::now().time_since_epoch().count()};

int tot = 0;

int q(int x, vector<int>& vis, int co, vector<int>& col) {
	int cnt = 1;
	for(int i = 1; i <= x; i++) 
		cnt += col[i] == co && !vis[i];
	if(cnt == 1)
		return -1;
	cout << "? " << cnt << " ";
	for(int i = 1; i <= x; i++)
		if(col[i] == co && !vis[i])
			cout << i << " ";
	cout << x << endl;
	int r1, r2;
	cin >> r1 >> r2;
	if(r1 == -1)
		return r1;
	return r1 + r2 - x;
}

void solve() {
	int n;
	cin >> n;
	vector<array<int, 2>> ans;
	vector<int> col(n + 1, 0);
	for(int i = 1; i <= n; i++) {
		vector<int> pos;
		vector<int> vis(n + 1, 0);
		for(int j = 1; j <= tot; j++) {
			int now = q(i, vis, j, col);
			if(now == -1)
				pos.push_back(j);
			while(now != -1) {
				vis[now] = 1;
				ans.push_back({now, i});
				now = q(i, vis, j, col);
			}
		} 
		if(!pos.size())
			col[i] = ++tot;
		else {
                         i64 qqq = rng();
                           
			col[i] = pos[abs(rng) % pos.size()];
		}
	}
	cout << "! " << ans.size() << endl;
	for(auto x : ans)
		cout << x[0] << ' ' << x[1] << endl; 
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}

Details

answer.code:12:74: warning: narrowing conversion of ‘std::chrono::_V2::steady_clock::now().std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >::time_since_epoch().std::chrono::duration<long int, std::ratio<1, 1000000000> >::count()’ from ‘std::chrono::duration<long int, std::ratio<1, 1000000000> >::rep’ {aka ‘long int’} to ‘std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>::result_type’ {aka ‘long unsigned int’} [-Wnarrowing]
   12 | mt19937_64 rng {std::chrono::steady_clock::now().time_since_epoch().count()};
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
answer.code: In function ‘void solve()’:
answer.code:57:41: error: no matching function for call to ‘abs(std::mt19937_64&)’
   57 |                         col[i] = pos[abs(rng) % pos.size()];
      |                                      ~~~^~~~~
In file included from /usr/include/c++/13/cstdlib:79,
                 from /usr/include/c++/13/ext/string_conversions.h:43,
                 from /usr/include/c++/13/bits/basic_string.h:4097,
                 from /usr/include/c++/13/string:54,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:840:21: note:   no known conversion for argument 1 from ‘std::mt19937_64’ {aka ‘std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>’} to ‘int’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |                 ~~~~^~~
In file included from /usr/include/c++/13/cstdlib:81:
/usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:79:19: note:   no known conversion for argument 1 from ‘std::mt19937_64’ {aka ‘std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>’} to ‘long double’
   79 |   abs(long double __x)
      |       ~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:75:13: note:   no known conversion for argument 1 from ‘std::mt19937_64’ {aka ‘std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>’} to ‘float’
   75 |   abs(float __x)
      |       ~~~~~~^~~
/usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:71:14: note:   no known conversion for argument 1 from ‘std::mt19937_64’ {aka ‘std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>’} to ‘double’
   71 |   abs(double __x)
      |       ~~~~~~~^~~
/usr/include/c++/13/bits/std_abs.h:61:3: note: candidate: ‘long long int std::abs(long long int)’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:61:17: note:   no known conversion for argument 1 from ‘std::mt19937_64’ {aka ‘std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>’} to ‘long long int’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |       ~~~~~~~~~~^~~
/usr/include/c++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:56:12: note:   no known conversion for argument 1 from ‘std::mt19937_64’ {aka ‘std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>’} to ‘long int’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |       ~~~~~^~~