QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#234864#6602. Journey to Un'GoroinvernoTL 2ms7432kbC++142.4kb2023-11-02 00:22:372023-11-02 00:22:37

Judging History

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

  • [2023-11-02 00:22:37]
  • 评测
  • 测评结果:TL
  • 用时:2ms
  • 内存:7432kb
  • [2023-11-02 00:22:37]
  • 提交

answer


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
#define wr(a,b) cout << a << " " << b << endl
#define fo(i,a,b) for (int i = a;i <= b;++ i)
#define fd(i,a,b) for (int i = a;i >= b;-- i)


#define int long long
using namespace std;

#ifdef OWO
#define debug(args...) LKJ("\033[1;32m[ " #args " ]\033[0m", args)
template<class I> void LKJ(I&&x){ cerr << x << '\n'; }
template<class I, class...T> void LKJ(I&&x, T&&...t){ cerr << x << ", ", LKJ(t...); }
template<class I> void OI(I a, I b){while(a < b) cerr << *a << " \n"[a+1 == b], ++a; }
#else
#define debug(...) 0
#define OI(...) 0
#endif


const int N = 1e5 + 10;
int T;
int A[N];
string st[N];
int n,cnt = 0, ans = 0;

void made1(int dt){
    ++cnt;
    fo (i,0,dt-1){
        fo (j,1,A[i]) cout << 'b';
        cout << 'r';
    }
    fo (j,1,A[dt]) cout << 'b';
    cout << '\n';
      OI(A,A+dt+1);
    return;
}

void made2(int dt){
    ++cnt;
    fo (i,0,dt-1){
        fo (j,1,A[i]) st[cnt] +='b';
        st[cnt] +='r';
    }
    fo (j,1,A[dt]) st[cnt] +='b';
      OI(A,A+dt+1);
    return;
}

void dfs(int w, int res, int sum) {

  if (cnt == 100) return;
  fd (i,min(res,n-w-sum),0) {
 //   wr(i,n-w-sum);
    //if (n-w==sum+i){
    A[w]=i;
      int dt = w;
      int ANS = 0;
      fo (i,0,dt) 
      for (int j = i + 1;j <= dt;j += 2)
        ANS += (A[i]+1) * (A[j]+1);
      if (ANS==ans){
        made2(dt);
      }
      //continue;
    //}
    dfs(w+1,res-i,sum+i);
  }
}

void solve()
{
    cin >> n;
  //  wr("----","----------------");
    int a = (n+1)/2, b = (n+2)/2;
    cnt = 0;
    cout << (ans=a * b) << endl;
    if (n >= 200) {
      A[0]=n/2;
      A[1]=n-1-A[0];
      made1(1);
      if (A[0] != A[1]) {
        A[0]--;
        A[1]++;
        made1(1);
        fo (i,0,48) {
          A[1]--;
          A[2]=i;
          made1(2);
          A[0]--;
          A[1]++;
          made1(2);
        }
      }
      else {
        fo (i,0,98) {
          A[0] = n-2-i-A[1];
          A[2] = i;
          made1(2);
        }
      }
      return;
    }
  //  wr("n=",n);
   // wr("ans=", (ans=a * b));
    dfs(0,n,0);
    //sort(st+1,st+1+cnt);
    fo(i,1,cnt) cout << st[i] << endl; 
}

signed main()
{
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    T = 1;
  //  cin >> T;
    while(T--)
    {
        solve();
    }
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6804kb

input:

1

output:

1
r

result:

ok 2 tokens

Test #2:

score: 0
Accepted
time: 1ms
memory: 6752kb

input:

2

output:

2
br
rb
rr

result:

ok 4 tokens

Test #3:

score: 0
Accepted
time: 0ms
memory: 6872kb

input:

3

output:

4
brb
rbr
rrr

result:

ok 4 tokens

Test #4:

score: 0
Accepted
time: 0ms
memory: 6760kb

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: 7356kb

input:

5

output:

9
bbrbb
brbbr
brbrr
brrrb
rbbrb
rbrbr
rbrrr
rrbrb
rrrbr
rrrrr

result:

ok 11 tokens

Test #6:

score: 0
Accepted
time: 1ms
memory: 6804kb

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: 7432kb

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: 1ms
memory: 6820kb

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: 1ms
memory: 6800kb

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: 1ms
memory: 6816kb

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: 1ms
memory: 6804kb

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: 2ms
memory: 6748kb

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: 1ms
memory: 6748kb

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: 6792kb

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: 7308kb

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: 1ms
memory: 7164kb

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: 1ms
memory: 7388kb

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: 1ms
memory: 7212kb

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: 1ms
memory: 6804kb

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: 1ms
memory: 6748kb

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: -100
Time Limit Exceeded

input:

50

output:

650

result: