| Task: | Enumeration |
| Sender: | Hornet's Multithreading |
| Submission time: | 2025-11-08 16:22:23 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | ACCEPTED | 0.00 s | details |
| #5 | WRONG ANSWER | 0.00 s | details |
| #6 | WRONG ANSWER | 0.00 s | details |
| #7 | WRONG ANSWER | 0.00 s | details |
| #8 | WRONG ANSWER | 0.00 s | details |
| #9 | WRONG ANSWER | 0.00 s | details |
| #10 | WRONG ANSWER | 0.00 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
bool check(int n, int x) {
int s = 0;
for (int i = n - 1; i >= 0; i--) {
if (x >> i & 1) {
s--;
} else {
s++;
}
if (s < 0) {
return false;
}
}
return s == 0;
}
int flip(int val, int x, int y) {
assert(x != y);
val ^= (1 << x);
val ^= (1 << y);
return val;
}
const int N = 20;
int n;
bool vis[1 << N];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cin >> n;
cout << string(n / 2, '(') << string(n / 2, ')') << '\n';
vis[(1 << (n / 2)) - 1] = true;
int cur = (1 << (n / 2)) - 1;
while (true) {
bool f = true;
for (int i = 0; i < n - 1; i++) {
int v = flip(cur, i, i + 1);
if (check(n, v) && !vis[v]) {
vis[v] = true;
cout << i + 1 << ' ' << i + 2 << '\n';
cur = v;
f = false;
break;
}
}
if (f) {
break;
}
}
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 2 |
| correct output |
|---|
| () |
| user output |
|---|
| () |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 4 |
| correct output |
|---|
| ()() 2 3 |
| user output |
|---|
| (()) 2 3 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 6 |
| correct output |
|---|
| ()()() 2 3 4 5 3 2 2 4 |
| user output |
|---|
| ((())) 3 4 2 3 4 5 2 3 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 8 |
| correct output |
|---|
| ()()()() 2 3 4 5 3 2 2 4 ... |
| user output |
|---|
| (((()))) 4 5 3 4 2 3 5 6 ... |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 |
| correct output |
|---|
| ()()()()() 2 3 4 5 3 2 2 4 ... |
| user output |
|---|
| ((((())))) 5 6 4 5 3 4 2 3 ... |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 12 |
| correct output |
|---|
| ()()()()()() 2 3 4 5 3 2 2 4 ... |
| user output |
|---|
| (((((()))))) 6 7 5 6 4 5 3 4 ... |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 14 |
| correct output |
|---|
| ()()()()()()() 2 3 4 5 3 2 2 4 ... |
| user output |
|---|
| ((((((())))))) 7 8 6 7 5 6 4 5 ... |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 16 |
| correct output |
|---|
| ()()()()()()()() 2 3 4 5 3 2 2 4 ... |
| user output |
|---|
| (((((((()))))))) 8 9 7 8 6 7 5 6 ... |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 18 |
| correct output |
|---|
| ()()()()()()()()() 2 3 4 5 3 2 2 4 ... |
| user output |
|---|
| ((((((((())))))))) 9 10 8 9 7 8 6 7 ... |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 20 |
| correct output |
|---|
| ()()()()()()()()()() 2 3 4 5 3 2 2 4 ... |
| user output |
|---|
| (((((((((()))))))))) 10 11 9 10 8 9 7 8 ... |
