QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#769972#5438. Half MixedFalse0099RE 0ms3616kbC++202.6kb2024-11-21 20:07:312024-11-21 20:07:32

Judging History

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

  • [2024-11-21 20:07:32]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3616kb
  • [2024-11-21 20:07:31]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
int INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
typedef pair<int, int> PII;
void init()
{
}
void solve()
{
    int n, m;
    cin >> n >> m;

    bool flag = 1;
    if (n > m)
    {
        flag = 0;
        swap(n, m);
    }
    if (n * (n + 1) * m * (m + 1) % 8 != 0)
    {
        cout << "No" << endl;
        return;
    }
    int need = n * (n + 1) * m * (m + 1) / 8;
    for (int i = 1; i <= m; i++)
    {
        for (int j = i; j <= m; j++)
        {
            int tot = 0;
            int len_left = (i - 1 - 1 + 1);
            int len_mid = (j - i + 1);
            int len_right = (m - (j + 1) + 1);
            tot += len_left * (len_left + 1) * n * (n + 1) / 4;
            tot += len_mid * (len_mid + 1) * n * (n + 1) / 4;
            tot += len_right * (len_right + 1) * n * (n + 1) / 4;
            // cout << i << " " << j << " " << tot << endl;
            if (tot == need)
            {
//                cout<<i<<" "<<j<<endl;
                cout << "Yes" << endl;
                vector<vector<int>> g(n + 1, vector<int>(m + 1));
                for (int _ = 1; _ <= n; _++)
                {
                    for (int __ = 1; __ <= i - 1; __++)
                    {
                        g[_][__] = 1;
                    }
                    for (int __ = i; __ <= j; __++)
                    {
                        g[_][__] = 0;
                    }
                    for (int __ = j + 1; __ <= m; __++)
                    {
                        g[_][__] = 1;
                    }
                }
                if (flag == 0)
                {
                    for (int _ = 1; _ <= m; _++)
                    {
                        for (int __ = 1; __ <= n; __++)
                        {
                            cout << g[_][__] << " ";
                        }
                        cout << endl;
                    }
                }
                else
                {
                    for (int _ = 1; _ <= n; _++)
                    {
                        for (int __ = 1; __ <= m; __++)
                        {
                            cout << g[_][__] << " ";
                        }
                        cout << endl;
                    }
                }
                return;
            }
        }
    }
}
signed main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    int t;
    t = 1;
    cin >> t;
    init();
    while (t--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 3
1 1

output:

Yes
1 0 1 
1 0 1 
No

result:

ok OK, Accepted. (2 test cases)

Test #2:

score: -100
Runtime Error

input:

5382
1 1
1 2
2 1
1 3
2 2
3 1
1 4
2 3
3 2
4 1
1 5
2 4
3 3
4 2
5 1
1 6
2 5
3 4
4 3
5 2
6 1
1 7
2 6
3 5
4 4
5 3
6 2
7 1
1 8
2 7
3 6
4 5
5 4
6 3
7 2
8 1
1 9
2 8
3 7
4 6
5 5
6 4
7 3
8 2
9 1
1 10
2 9
3 8
4 7
5 6
6 5
7 4
8 3
9 2
10 1
1 11
2 10
3 9
4 8
5 7
6 6
7 5
8 4
9 3
10 2
11 1
1 12
2 11
3 10
4 9
5 8
6 ...

output:


result: