QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#234853#6602. Journey to Un'GoroinvernoWA 0ms3744kbC++142.7kb2023-11-01 23:58:162023-11-01 23:58:17

Judging History

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

  • [2023-11-01 23:58:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3744kb
  • [2023-11-01 23:58:16]
  • 提交

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;
char st[N];
  
void solve2()
{
    int n, m;
    cin >> n;
    int a = (n+1)/2, b = (n+2)/2;
    cout << a * b << endl;
    if (n==3) {
      cout << "brb\nrbr\nrrr\n";
      return;
    }
    if (n==1) {
      cout << "r\n";
      return;
    }
    int w = min(n/2,8*1ll);
    fo (i,1,n) st[i] = 'r'; 
    st[n+1] = '\0';
    m = n - 1;
    fo (h,0,min(1<<w-1,100-1)) {
      int hh = h;
      for (int j = m;j >= 1;j -= 2,hh>>=1){
        st[j] = (hh&1)?'r':'b';
      }
      cout << st+1 << endl;
    }
}

int A[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 dfs(int w, int dt, int res) {
  if (cnt == 100) return;
  if (w == dt){
    A[w] = res;
    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){
      made1(dt);
    }
    return;
  }
  fd (i,res,0) {
    A[w]=i;
    dfs(w+1,dt,res-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));
    fo (k,1,n) {
      fo (i,1,n) A[i] = 0;
      //wr("k",k);
      dfs(0,k,n-k);
    }

}

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: 0ms
memory: 3660kb

input:

1

output:

1
r

result:

ok 2 tokens

Test #2:

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

input:

2

output:

2
br
rb
rr

result:

ok 4 tokens

Test #3:

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

input:

3

output:

4
brb
rbr
rrr

result:

ok 4 tokens

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3744kb

input:

4

output:

6
bbrb
brbb
brbr
rbbr
rbrb
brrr
rbrr
rrbr
rrrb
rrrr

result:

wrong answer 5th words differ - expected: 'brrr', found: 'rbbr'