QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#482751#9114. Black or White 2ucup-team2307#AC ✓398ms6004kbC++203.2kb2024-07-17 21:13:592024-07-17 21:13:59

Judging History

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

  • [2024-07-17 21:13:59]
  • 评测
  • 测评结果:AC
  • 用时:398ms
  • 内存:6004kb
  • [2024-07-17 21:13:59]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
#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()
using pii = pair<int, int>;
using vi = vector<int>;
#define fi first
#define se second
#define pb push_back

int sz[3030];
int sm[3030];
bool can[1550*1550];

bool solve(int n, int m, int k, bool alr = false)
{
    if (n==2 && m==2 && k == 2)
    {
        cout<<"00\n";
        cout<<"11\n";
        return false;
    }

    int N = 0;
    for (int s=0; s<=n-1+m-1; s++)
    {
        int cur = 0;
        for (int i=0; i<n; i++)
        {
            int j = s-i;
            if (j>=0 && j<m)
                cur++;
        }
        N++;
        sz[N] = cur;
    }

    sm[0] = 0;
    for (int i=1; i<=N; i++)
        sm[i] = sm[i-1] + sz[i];


    for (int l=1; l<=N; l++)
        for (int r=l+1; r<=N; r++)
        {
            if (sm[r] - sm[l-1] == k)
            {
                l--;
                r--;
                for (int i=0; i<n; i++, cout<<"\n")
                    for (int j=0; j<m; j++)
                        cout<<(((i+j>=l) && (i+j<=r))^alr);
                return true;
            }
        }
    for (int i=0; i<=n*m; i++)
        can[i] = false;
    int mxl = 1;
    int mxr = 1;
    for (int i=2; i<=N; i++)
    {
        if (sz[i] > sz[mxl])
            mxl = i;
        if (sz[i] >= sz[mxr])
            mxr = i;
    }
    for (int l=1; l<mxl; l++)
        for (int r=l+1; r<mxl; r++)
            can[sm[r] - sm[l-1]] = true;
//    for (int i=1; i<=N; i++)
//        cout<<sz[i]<<" ";
//    cout<<"\n";
//    for (int i=0; i<=n*m; i++)
//        cout<<can[i]<<" ";
//    cout<<"\n";
    for (int l=mxl+2; l<=N; l++)
        for (int r=l+1; r<=N; r++)
            if (k > sm[r] - sm[l-1])
            {
//                cout<<k-(sm[r]-sm[l-1])<<"\n";
                if (can[k-(sm[r]-sm[l-1])])
                {
                    for (int l1=1; l1<mxl; l1++)
                        for (int r1=l1+1; r1<mxl; r1++)
                            if (k-(sm[r]-sm[l-1]) == sm[r1]-sm[l1-1])
                        {
    l--;
    r--;
    l1--;
    r1--;
                    for (int i=0; i<n; i++, cout<<"\n")
                        for (int j=0; j<m; j++)
                            cout<<((((i+j>=l) && (i+j<=r)) || ((i+j>=l1) && (i+j<=r1)))^alr);
                            return true;
                        }
                }
            }

    if (!alr)
        return solve(n, m, n*m-k, true);
    else
        return false;
    return true;
}

signed main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);

    int t;
    cin>>t;
    while (t--)
    {
        int n, m, k;
        cin>>n>>m>>k;
        solve(n, m, k);
    }
//    for (int n=2; n<=10; n++)
//        for (int m=n; m<=10; m++)
//
//    {
////        cout<<setw(2)<<n<<" "<<setw(2)<<m<<" : ";
//        for (int i=0; i<=n*m-i; i++)
//            if (!solve(n, m, i))
//                cout<<n<<" "<<m<<" "<<i<<endl;
////        cout<<"\n";
//    }

}
/*
2 2 2
4 4 8
5 5 8
5 6 8
5 7 8
*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

input:

2
2 2 2
2 3 0

output:

00
11
000
000

result:

ok Output is valid. OK.

Test #2:

score: 0
Accepted
time: 119ms
memory: 3748kb

input:

27520
2 2 0
2 2 1
2 2 2
2 2 3
2 2 4
2 3 0
2 3 1
2 3 2
2 3 3
2 3 4
2 3 5
2 3 6
3 2 0
3 2 1
3 2 2
3 2 3
3 2 4
3 2 5
3 2 6
3 3 0
3 3 1
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
3 3 8
3 3 9
2 4 0
2 4 1
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
2 4 7
2 4 8
3 4 0
3 4 1
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10...

output:

00
00
00
01
00
11
11
10
11
11
000
000
000
001
100
001
110
100
011
110
111
110
111
111
00
00
00
00
00
01
10
00
01
11
10
00
01
11
10
11
11
10
11
11
11
000
000
000
000
000
001
100
000
001
110
100
000
100
001
011
011
110
100
111
110
100
011
111
110
111
111
110
111
111
111
0000
0000
0000
0001
1000
0001
1...

result:

ok Output is valid. OK.

Test #3:

score: 0
Accepted
time: 105ms
memory: 4988kb

input:

162
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9
...

output:

00
11
100
001
110
100
011
110
10
00
01
11
10
00
01
11
10
100
000
001
110
100
000
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
1100
1000
0110
1100
1110
1100
0111
1110
1000
0000
0001
1100
1000
0000
1000
0001
0011
0110
1100
1000
1110
1100
1000
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #4:

score: 0
Accepted
time: 106ms
memory: 4792kb

input:

163
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9
...

output:

00
11
100
001
110
100
011
110
10
00
01
11
10
00
01
11
10
100
000
001
110
100
000
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
1100
1000
0110
1100
1110
1100
0111
1110
1000
0000
0001
1100
1000
0000
1000
0001
0011
0110
1100
1000
1110
1100
1000
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #5:

score: 0
Accepted
time: 103ms
memory: 4620kb

input:

165
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9
...

output:

00
11
100
001
110
100
011
110
10
00
01
11
10
00
01
11
10
100
000
001
110
100
000
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
1100
1000
0110
1100
1110
1100
0111
1110
1000
0000
0001
1100
1000
0000
1000
0001
0011
0110
1100
1000
1110
1100
1000
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #6:

score: 0
Accepted
time: 380ms
memory: 3784kb

input:

1020
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9...

output:

00
11
100
001
110
100
011
110
10
00
01
11
10
00
01
11
10
100
000
001
110
100
000
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
1100
1000
0110
1100
1110
1100
0111
1110
1000
0000
0001
1100
1000
0000
1000
0001
0011
0110
1100
1000
1110
1100
1000
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #7:

score: 0
Accepted
time: 367ms
memory: 3720kb

input:

1012
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9...

output:

00
11
100
001
110
100
011
110
10
00
01
11
10
00
01
11
10
100
000
001
110
100
000
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
1100
1000
0110
1100
1110
1100
0111
1110
1000
0000
0001
1100
1000
0000
1000
0001
0011
0110
1100
1000
1110
1100
1000
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #8:

score: 0
Accepted
time: 398ms
memory: 3616kb

input:

1033
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9...

output:

00
11
100
001
110
100
011
110
10
00
01
11
10
00
01
11
10
100
000
001
110
100
000
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
1100
1000
0110
1100
1110
1100
0111
1110
1000
0000
0001
1100
1000
0000
1000
0001
0011
0110
1100
1000
1110
1100
1000
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #9:

score: 0
Accepted
time: 122ms
memory: 3624kb

input:

100000
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4...

output:

00
11
100
001
110
100
011
110
10
00
01
11
10
00
01
11
10
100
000
001
110
100
000
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
1100
1000
0110
1100
1110
1100
0111
1110
1000
0000
0001
1100
1000
0000
1000
0001
0011
0110
1100
1000
1110
1100
1000
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #10:

score: 0
Accepted
time: 54ms
memory: 3628kb

input:

100000
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4...

output:

00
11
100
001
110
100
011
110
10
00
01
11
10
00
01
11
10
100
000
001
110
100
000
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
1100
1000
0110
1100
1110
1100
0111
1110
1000
0000
0001
1100
1000
0000
1000
0001
0011
0110
1100
1000
1110
1100
1000
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #11:

score: 0
Accepted
time: 54ms
memory: 3632kb

input:

100000
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4...

output:

00
11
100
001
110
100
011
110
10
00
01
11
10
00
01
11
10
100
000
001
110
100
000
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
1100
1000
0110
1100
1110
1100
0111
1110
1000
0000
0001
1100
1000
0000
1000
0001
0011
0110
1100
1000
1110
1100
1000
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #12:

score: 0
Accepted
time: 98ms
memory: 3788kb

input:

3
1500 1500 2250000
1322 1322 1747684
1158 2 2316

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok Output is valid. OK.

Test #13:

score: 0
Accepted
time: 104ms
memory: 6004kb

input:

3
1500 1500 1125000
1322 1322 873842
1158 2 1158

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok Output is valid. OK.

Extra Test:

score: 0
Extra Test Passed