QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#629843#9428. Be Positiveqwqpmp#WA 0ms3652kbC++141.2kb2024-10-11 15:10:082024-10-11 15:10:10

Judging History

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

  • [2024-10-11 15:10:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3652kb
  • [2024-10-11 15:10:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,a,n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define endl '\n'
#define SZ(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
const ll mod = 1000000007;
// head

int n;

void solve() {
	cin >> n;
	ll pre = 0;
	vi rs;
	rep(i,0,n) pre ^= i, rs.pb(i); 
	if (!pre) {
		cout << "impossible" << endl; 
		return;
	} 
	while (1) {
		random_shuffle(all(rs));
		// for (auto x : rs) cerr << x << " ";
		// cerr << "\n";
		ll rpre = 0, ok = 0;
		rep(i,0,n) {
			rpre ^= rs[i];
			ok |= (rpre == 0);
			if (ok) break;
		}
		if (!ok) {
			for (auto x : rs) cout << x << " ";
			cout << endl;
			break;
		}
	} 
}

int tc;
signed main() {
	ios::sync_with_stdio(0);

	// freopen("qwq.in","r",stdin);
	// freopen("qwq.out","w",stdout);

	cin >> tc;
	while (tc --) solve();
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3652kb

input:

4
1
2
3
4

output:

impossible
1 0 
2 0 1 
impossible

result:

wrong answer Jury has better answer (test case 3)