QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#761393 | #6602. Journey to Un'Goro | fosov | WA | 0ms | 3720kb | C++14 | 1.4kb | 2024-11-18 22:33:45 | 2024-11-18 22:33:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lll __int128
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define pii pair<int, int>
#define pdd pair<double, double>
#define N 100010
int n, tot;
string cur;
bool valid(string x) {
vector<int> pre(n+1, 0);
for (int i = 1; i <= n; ++ i) pre[i] = (pre[i-1] + (x[i-1] == 'r')) % 2;
int c0 = 0, c1 = 0;
for (int i = 0; i <= n; ++ i) {
c0 += pre[i] == 0;
c1 += pre[i] == 1;
}
if (n%2 == 0) return c0 == c1 + 1 || c1 == c0 + 1;
if (n%2 == 1) return c0 == c1;
return 0;
}
void dfs(int idx, int cp0, int cp1, int cp) {
if (tot == 100) return;
if (cp1 - (cp0 + n - idx) > 1) return;
if (cp0 - (cp1 + n - idx) > 1) return;
if (idx == n && abs(cp0 - cp1) != ((n&1)^1)) return;
if (idx == n) {
assert(valid(cur));
cout << cur << '\n';
}
cur[idx] = 'b';
dfs(idx+1, cp0+(cp==0), cp1+(cp==1), cp);
cur[idx] = 'r';
dfs(idx+1, cp0+(cp==1), cp1+(cp==0), cp^1);
}
int main() {
#ifdef TEST
freopen("zz.in", "r+", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
cur = string(n, '0');
tot = 0;
cout << 1ll * ((n+1)/2) * (n+1-(n+1)/2) << '\n';
dfs(0, 1, 0, 0);
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3508kb
input:
1
output:
1 r
result:
ok 2 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
2
output:
2 br rb rr
result:
ok 4 tokens
Test #3:
score: 0
Accepted
time: 0ms
memory: 3444kb
input:
3
output:
4 brb rbr rrr
result:
ok 4 tokens
Test #4:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
4
output:
6 bbrb brbb brbr brrr rbbr rbrb rbrr rrbr rrrb rrrr
result:
ok 11 tokens
Test #5:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
5
output:
9 bbrbb brbbr brbrr brrrb rbbrb rbrbr rbrrr rrbrb rrrbr rrrrr
result:
ok 11 tokens
Test #6:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
6
output:
12 bbbrbb bbrbbb bbrbbr bbrbrr bbrrrb brbbbr brbbrb brbbrr brbrbr brbrrb brbrrr brrbrb brrrbb brrrbr brrrrr rbbbrb rbbrbb rbbrbr rbbrrr rbrbbr rbrbrb rbrbrr rbrrbr rbrrrb rbrrrr rrbbrb rrbrbb rrbrbr rrbrrr rrrbbr rrrbrb rrrbrr rrrrbr rrrrrb rrrrrr
result:
ok 36 tokens
Test #7:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
7
output:
16 bbbrbbb bbrbbbr bbrbbrr bbrbrrb bbrrrbb brbbbrb brbbrbr brbbrrr brbrbrb brbrrbr brbrrrr brrbrbb brrrbbr brrrbrr brrrrrb rbbbrbb rbbrbbr rbbrbrr rbbrrrb rbrbbrb rbrbrbr rbrbrrr rbrrbrb rbrrrbr rbrrrrr rrbbrbb rrbrbbr rrbrbrr rrbrrrb rrrbbrb rrrbrbr rrrbrrr rrrrbrb rrrrrbr rrrrrrr
result:
ok 36 tokens
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3560kb
input:
8
output:
20 bbbbrbbb bbbrbbbb bbbrbbbr bbbrbbrr bbbrbrrb bbbrrrbb bbrbbbbr bbrbbbrb bbrbbbrr bbrbbrbr bbrbbrrb bbrbbrrr bbrbrbrb bbrbrrbb bbrbrrbr bbrbrrrr bbrrbrbb bbrrrbbb bbrrrbbr bbrrrbrr bbrrrrrb brbbbbrb brbbbrbb brbbbrbr brbbbrrr brbbrbbr brbbrbrb brbbrbrr brbbrrbr brbbrrrb brbbrrrr brbrbbrb brbrbrbb ...
result:
wrong answer Participant output contains extra tokens