QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#233087#6743. water235dkdkWA 6ms27112kbC++203.6kb2023-10-31 13:06:112023-10-31 13:06:12

Judging History

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

  • [2023-10-31 13:06:12]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:27112kb
  • [2023-10-31 13:06:11]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <cmath>
#include <string>
#include <set>
#include <iomanip>
#define ft first
#define sd second
#define endl '\n'
#define lowbit(x) (x & (-x))
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PUU = pair<ULL, ULL>;
using PLL = pair<LL, LL>;
using i128 = __int128;
const double eps = 1e-9;
const int N = 1000010, mod = 80112002, INF = 2147483647;
int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
int qmi(int a, int b)
{
    int res = 1, t = a;
    while(b)
    {
        if(b & 1)res = (LL)res * t;
        t = (LL)t * t;
        b >>= 1;
    }
    return res;
}

int n, m;
vector<int> w[N];

void solve()
{
    int cnt = 0;
    cin >> n >> m;

    for(int i = 0; i < n ; i++)
        for(int j = 0; j < m ; j++)
            w[i].push_back(0);

    if(n == 1)
    {
        cout << m / 2 + 1 << endl;
        if(m % 2 == 0)
        {
            for(int i = 0; i < m ; i++)
            {
                if(i == 0)cout << 1;
                else if(i % 2)cout << 1;
                else cout << 0;
                if(i < m - 1)cout << ' ';
            }
        }
        else
        {
            for(int i = 0; i < m ; i++)
            {
                if(i % 2 == 0)cout << 1;
                else cout << 0;
                if(i < m - 1)cout << ' ';
            }
        }

        return;
    }

    if(m == 1)
    {
        cout << n / 2 + 1 << endl;
        if(n % 2 == 0)
        {
            for(int i = 0; i < n ; i++)
            {
                if(i == 0)cout << 1;
                else if(i % 2)cout << 1;
                else cout << 0;
                if(i < n - 1)cout << endl;
            }
        }
        else
        {
            for(int i = 0; i < n ; i++)
            {
                if(i % 2 == 0)cout << 1;
                else cout << 0;
                if(i < n - 1)cout << endl;
            }
        }

        return;
    }

    if(n == m)
    {
        cout << n << endl;
        for(int i = 1; i <= n ; i++)
        {
            for(int j = 1; j <= m ; j++)
            {
                if(i == j)cout << 1;
                else cout << 0;
                if(j < m)cout << ' ';
            }
            if(i < n)cout << endl;
        }
    }
    else if(n < m)
    {
        for(int i = 0; i < n ; i++)
            for(int j = 0; j < m ; j++)
                if(j % n == i)
                    w[i][j] = 1, cnt++;

        cout << cnt << endl;
        for(int i = 0; i < n ; i++)
        {
            for(int j = 0; j < m ; j++)
            {
                cout << w[i][j];
                if(j < m - 1)cout << ' ';
            }
            if(i < n - 1)cout << endl;
        }
    }
    else
    {
        for(int i = 0; i < n ; i++)
            for(int j = 0; j < m ; j++)
                if(i % m == j)
                    w[i][j] = 1, cnt++;

        cout << cnt << endl;
        for(int i = 0; i < n ; i++)
        {
            for(int j = 0; j < m ; j++)
            {
                cout << w[i][j];
                if(j < m - 1)cout << ' ';
            }
            if(i < n - 1)cout << endl;
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    //cout << setprecision(20);
    //init();

    int T = 1;
    //cin >> T;
    while(T -- )solve();
    return 0;
}

詳細信息

Test #1:

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

input:

2 1

output:

2
1
1

result:

ok The answer is correct.

Test #2:

score: 0
Accepted
time: 3ms
memory: 27048kb

input:

3 3

output:

3
1 0 0
0 1 0
0 0 1

result:

ok The answer is correct.

Test #3:

score: 0
Accepted
time: 3ms
memory: 27040kb

input:

1 4

output:

3
1 1 0 1

result:

ok The answer is correct.

Test #4:

score: 0
Accepted
time: 3ms
memory: 27104kb

input:

2 2

output:

2
1 0
0 1

result:

ok The answer is correct.

Test #5:

score: -100
Wrong Answer
time: 6ms
memory: 27112kb

input:

2 4

output:

4
1 0 1 0
0 1 0 1

result:

wrong answer The answer is wrong: expected = 3, found = 4