QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#546749 | #6602. Journey to Un'Goro | ucup-team1001# | WA | 1ms | 3876kb | C++20 | 5.5kb | 2024-09-04 12:56:03 | 2024-09-04 12:56:03 |
Judging History
answer
/*
Author: Haze
2024/9/4
*/
#include <bits/stdc++.h>
#define irep(i, l, r) for(int i = (l); i <= (r); ++ i)
#define drep(i, r, l) for(int i = (r); i >= (l); -- i)
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr);
using namespace std;
typedef long long ll;
inline ll readL() {
ll s = 0;
bool fl = false;
char ch = (char) getchar();
while (!isdigit(ch)) {
if (ch == '-')fl = true;
ch = (char) getchar();
}
while (isdigit(ch)) {
s = s * 10 + (ch ^ 48);
ch = (char) getchar();
}
return fl ? -s : s;
}
inline int read() {
return (int) (readL());
}
const int mod = 1000000000 + 7;
const int itinf = 1000000999;
const ll llinf = 2e18;
const int N = 500099;
//203
ll f[210][210];
void solve2(int n, ll goal){
//b for 0
// f[0][0].insert(0);
irep(len, 0, n){
irep(i, 0, len){
int j = len - i;
//i odd, j even, pair
f[i][j + 1]=max(f[i][j + 1], f[i][j] + i);
f[j + 1][i] = max(f[j + 1][i], f[i][j] + j + 1);
}
}
// irep(i, 1, 20){
// irep(j, 1, 20){
// cout << f[i][j] << ' ';
// }
// cout << endl;
// }
string ans;
int counter = 0;
ll res = goal;
function<void(int, ll,ll)> dfs = [&](int i, ll even, ll odd){
// cerr << i << ' ' << res << endl;
if(i == n){
cout << ans << '\n';
++ counter;
if(counter == 100)exit(0);
return;
}
//i odd, j even, pair
//b
ll remain = n - i - 1;
ll R = res;
for(ll codd = 0; codd <= remain; ++ codd){
ll ceven = remain - codd;
if(f[codd][ceven] + codd * even + ceven * odd + odd + codd == res){
ans.push_back('b');
res = R - odd;
dfs(i + 1, even + 1, odd);
res = R;
ans.pop_back();
break;
}
}
for(ll codd = 0; codd <= remain; ++ codd){
ll ceven = remain - codd;
if(f[codd][ceven] + codd * odd + ceven * even + even + ceven + 1 == res){
ans.push_back('r');
res = R - even - 1;
dfs(i + 1, odd, 1 + even);
res = R;
ans.pop_back();
break;
}
}
};
dfs(0,0,0);
}
void solve() {
map<int, vector<int>> mp;
int n = readL();
long long sums = 0;
for (int i = 1; i <= n; i++) {
sums += (n - i + 2) / 2;
}
cout << sums << endl;
if (n > 203) {
string s;
int k = (n + 1) / 2;
int left = n - k;
for (int i = 0; i < left; i++) {
s.push_back('b');
}
s.push_back('r');
for (int i = 1; i < k; i++) {
s.push_back('b');
}
vector<string> m = {s};
s = "";
for (int i = 0; i < left - 1; i++) {
s.push_back('b');
}
s.push_back('r');
for (int i = 0; i <= k; i++) {
int lefts = k - i;
int rr = min(k, lefts + 2);
string ss = s;
for (int j = 1; j <= lefts; j++) {
ss.push_back('b');
}
for (int j = lefts + 1; j <= rr; j++) {
ss.push_back('r');
}
for (int j = rr + 1; j <= k; j++) {
ss.push_back('b');
}
m.push_back(ss);
if (m.size() == 100) break;
}
for (auto j: m) {
cout << j << endl;
}
return;
}
solve2(n, sums);
// int maxs = 0;
//
// {
// //
// ll z = (1ll << (n)) - 1;
// vector<int> pre(n + 1);
// for (int j = 1; j <= n; j++) {
// pre[j] = (z >> (j - 1)) & 1;
// pre[j] += pre[j - 1];
// }
// int sums = 0;
// for (int j = 1; j <= n; ++j) {
// for (int k = j; k <= n; k++) {
// if ((pre[k] - pre[j - 1]) % 2 == 1) {
// sums++;
// }
// }
// }
// maxs = sums;
//
// }
// int f = (n - 1) / 2;
// int to = (f + 2);
// cerr << f << " " << to << endl;
// for (ll i = (1); i < (1 << n); i++) {
//
//// if (n > 20 && i > (1 << (18 + 1)))break;
// vector<ll> pre(n + 1);
//
// for (int j = 1; j <= n; j++) {
// pre[j] = (i >> (j - 1)) & 1;
// pre[j] += pre[j - 1];
// }
//
// int sums = 0;
// for (int j = 1; j <= n; ++j) {
// for (int k = j; k <= n; k++) {
// if ((pre[k] - pre[j - 1]) % 2 == 1) {
// sums++;
// }
// }
// }
// if (sums == maxs) {
//
// mp[sums].emplace_back(i);
//
// if (mp[sums].size() > 100) break;
// }
// }
// auto [i, j] = *mp.rbegin();
//// cerr << i << endl;
// int t = 0;
//
// for (auto k: j) {
// t++;
// if (t > 100) break;
// cerr << bitset<12>(k) << "\n";
// }
// for (auto [i, j]: mp) {
// cerr << i << " :\n";
// for (auto k: j) cerr << bitset<20>(k) << "\n";
// cerr << "\n";
// }
}
int main() {
// IOS
int T = 1;
while (T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3540kb
input:
1
output:
1 r
result:
ok 2 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
2
output:
2 br rb rr
result:
ok 4 tokens
Test #3:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
3
output:
4 brb rbr rrr
result:
ok 4 tokens
Test #4:
score: 0
Accepted
time: 0ms
memory: 3544kb
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: 3600kb
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: 3488kb
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: 3496kb
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: 0
Accepted
time: 0ms
memory: 3552kb
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:
ok 101 tokens
Test #9:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
9
output:
25 bbbbrbbbb bbbrbbbbr bbbrbbbrr bbbrbbrrb bbbrbrrbb bbbrrrbbb bbrbbbbrb bbrbbbrbr bbrbbbrrr bbrbbrbrb bbrbbrrbr bbrbbrrrr bbrbrbrbb bbrbrrbbr bbrbrrbrr bbrbrrrrb bbrrbrbbb bbrrrbbbr bbrrrbbrr bbrrrbrrb bbrrrrrbb brbbbbrbb brbbbrbbr brbbbrbrr brbbbrrrb brbbrbbrb brbbrbrbr brbbrbrrr brbbrrbrb brbbrrr...
result:
ok 101 tokens
Test #10:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
10
output:
30 bbbbbrbbbb bbbbrbbbbb bbbbrbbbbr bbbbrbbbrr bbbbrbbrrb bbbbrbrrbb bbbbrrrbbb bbbrbbbbbr bbbrbbbbrb bbbrbbbbrr bbbrbbbrbr bbbrbbbrrb bbbrbbbrrr bbbrbbrbrb bbbrbbrrbb bbbrbbrrbr bbbrbbrrrr bbbrbrbrbb bbbrbrrbbb bbbrbrrbbr bbbrbrrbrr bbbrbrrrrb bbbrrbrbbb bbbrrrbbbb bbbrrrbbbr bbbrrrbbrr bbbrrrbrrb ...
result:
ok 101 tokens
Test #11:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
11
output:
36 bbbbbrbbbbb bbbbrbbbbbr bbbbrbbbbrr bbbbrbbbrrb bbbbrbbrrbb bbbbrbrrbbb bbbbrrrbbbb bbbrbbbbbrb bbbrbbbbrbr bbbrbbbbrrr bbbrbbbrbrb bbbrbbbrrbr bbbrbbbrrrr bbbrbbrbrbb bbbrbbrrbbr bbbrbbrrbrr bbbrbbrrrrb bbbrbrbrbbb bbbrbrrbbbr bbbrbrrbbrr bbbrbrrbrrb bbbrbrrrrbb bbbrrbrbbbb bbbrrrbbbbr bbbrrrbbb...
result:
ok 101 tokens
Test #12:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
12
output:
42 bbbbbbrbbbbb bbbbbrbbbbbb bbbbbrbbbbbr bbbbbrbbbbrr bbbbbrbbbrrb bbbbbrbbrrbb bbbbbrbrrbbb bbbbbrrrbbbb bbbbrbbbbbbr bbbbrbbbbbrb bbbbrbbbbbrr bbbbrbbbbrbr bbbbrbbbbrrb bbbbrbbbbrrr bbbbrbbbrbrb bbbbrbbbrrbb bbbbrbbbrrbr bbbbrbbbrrrr bbbbrbbrbrbb bbbbrbbrrbbb bbbbrbbrrbbr bbbbrbbrrbrr bbbbrbbrrrr...
result:
ok 101 tokens
Test #13:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
13
output:
49 bbbbbbrbbbbbb bbbbbrbbbbbbr bbbbbrbbbbbrr bbbbbrbbbbrrb bbbbbrbbbrrbb bbbbbrbbrrbbb bbbbbrbrrbbbb bbbbbrrrbbbbb bbbbrbbbbbbrb bbbbrbbbbbrbr bbbbrbbbbbrrr bbbbrbbbbrbrb bbbbrbbbbrrbr bbbbrbbbbrrrr bbbbrbbbrbrbb bbbbrbbbrrbbr bbbbrbbbrrbrr bbbbrbbbrrrrb bbbbrbbrbrbbb bbbbrbbrrbbbr bbbbrbbrrbbrr bbb...
result:
ok 101 tokens
Test #14:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
14
output:
56 bbbbbbbrbbbbbb bbbbbbrbbbbbbb bbbbbbrbbbbbbr bbbbbbrbbbbbrr bbbbbbrbbbbrrb bbbbbbrbbbrrbb bbbbbbrbbrrbbb bbbbbbrbrrbbbb bbbbbbrrrbbbbb bbbbbrbbbbbbbr bbbbbrbbbbbbrb bbbbbrbbbbbbrr bbbbbrbbbbbrbr bbbbbrbbbbbrrb bbbbbrbbbbbrrr bbbbbrbbbbrbrb bbbbbrbbbbrrbb bbbbbrbbbbrrbr bbbbbrbbbbrrrr bbbbbrbbbrbr...
result:
ok 101 tokens
Test #15:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
15
output:
64 bbbbbbbrbbbbbbb bbbbbbrbbbbbbbr bbbbbbrbbbbbbrr bbbbbbrbbbbbrrb bbbbbbrbbbbrrbb bbbbbbrbbbrrbbb bbbbbbrbbrrbbbb bbbbbbrbrrbbbbb bbbbbbrrrbbbbbb bbbbbrbbbbbbbrb bbbbbrbbbbbbrbr bbbbbrbbbbbbrrr bbbbbrbbbbbrbrb bbbbbrbbbbbrrbr bbbbbrbbbbbrrrr bbbbbrbbbbrbrbb bbbbbrbbbbrrbbr bbbbbrbbbbrrbrr bbbbbrbbb...
result:
ok 101 tokens
Test #16:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
16
output:
72 bbbbbbbbrbbbbbbb bbbbbbbrbbbbbbbb bbbbbbbrbbbbbbbr bbbbbbbrbbbbbbrr bbbbbbbrbbbbbrrb bbbbbbbrbbbbrrbb bbbbbbbrbbbrrbbb bbbbbbbrbbrrbbbb bbbbbbbrbrrbbbbb bbbbbbbrrrbbbbbb bbbbbbrbbbbbbbbr bbbbbbrbbbbbbbrb bbbbbbrbbbbbbbrr bbbbbbrbbbbbbrbr bbbbbbrbbbbbbrrb bbbbbbrbbbbbbrrr bbbbbbrbbbbbrbrb bbbbbbrb...
result:
ok 101 tokens
Test #17:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
17
output:
81 bbbbbbbbrbbbbbbbb bbbbbbbrbbbbbbbbr bbbbbbbrbbbbbbbrr bbbbbbbrbbbbbbrrb bbbbbbbrbbbbbrrbb bbbbbbbrbbbbrrbbb bbbbbbbrbbbrrbbbb bbbbbbbrbbrrbbbbb bbbbbbbrbrrbbbbbb bbbbbbbrrrbbbbbbb bbbbbbrbbbbbbbbrb bbbbbbrbbbbbbbrbr bbbbbbrbbbbbbbrrr bbbbbbrbbbbbbrbrb bbbbbbrbbbbbbrrbr bbbbbbrbbbbbbrrrr bbbbbbrbb...
result:
ok 101 tokens
Test #18:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
18
output:
90 bbbbbbbbbrbbbbbbbb bbbbbbbbrbbbbbbbbb bbbbbbbbrbbbbbbbbr bbbbbbbbrbbbbbbbrr bbbbbbbbrbbbbbbrrb bbbbbbbbrbbbbbrrbb bbbbbbbbrbbbbrrbbb bbbbbbbbrbbbrrbbbb bbbbbbbbrbbrrbbbbb bbbbbbbbrbrrbbbbbb bbbbbbbbrrrbbbbbbb bbbbbbbrbbbbbbbbbr bbbbbbbrbbbbbbbbrb bbbbbbbrbbbbbbbbrr bbbbbbbrbbbbbbbrbr bbbbbbbrbbbb...
result:
ok 101 tokens
Test #19:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
19
output:
100 bbbbbbbbbrbbbbbbbbb bbbbbbbbrbbbbbbbbbr bbbbbbbbrbbbbbbbbrr bbbbbbbbrbbbbbbbrrb bbbbbbbbrbbbbbbrrbb bbbbbbbbrbbbbbrrbbb bbbbbbbbrbbbbrrbbbb bbbbbbbbrbbbrrbbbbb bbbbbbbbrbbrrbbbbbb bbbbbbbbrbrrbbbbbbb bbbbbbbbrrrbbbbbbbb bbbbbbbrbbbbbbbbbrb bbbbbbbrbbbbbbbbrbr bbbbbbbrbbbbbbbbrrr bbbbbbbrbbbbbbbr...
result:
ok 101 tokens
Test #20:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
20
output:
110 bbbbbbbbbbrbbbbbbbbb bbbbbbbbbrbbbbbbbbbb bbbbbbbbbrbbbbbbbbbr bbbbbbbbbrbbbbbbbbrr bbbbbbbbbrbbbbbbbrrb bbbbbbbbbrbbbbbbrrbb bbbbbbbbbrbbbbbrrbbb bbbbbbbbbrbbbbrrbbbb bbbbbbbbbrbbbrrbbbbb bbbbbbbbbrbbrrbbbbbb bbbbbbbbbrbrrbbbbbbb bbbbbbbbbrrrbbbbbbbb bbbbbbbbrbbbbbbbbbbr bbbbbbbbrbbbbbbbbbrb bb...
result:
ok 101 tokens
Test #21:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
50
output:
650 bbbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbr bbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbrr bbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbrrb bbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbb...
result:
ok 101 tokens
Test #22:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
51
output:
676 bbbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbbr bbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbrr bbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbrrb bbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbrrbb bbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbb...
result:
ok 101 tokens
Test #23:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
100
output:
2550 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
result:
ok 101 tokens
Test #24:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
101
output:
2601 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbr bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
result:
ok 101 tokens
Test #25:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
500
output:
62750 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
result:
ok 101 tokens
Test #26:
score: -100
Wrong Answer
time: 1ms
memory: 3672kb
input:
501
output:
63001 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
result:
wrong answer 3rd words differ - expected: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbr', found: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'