QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103277#6309. AqreNerovix#WA 2ms3316kbC++201.8kb2023-05-04 23:02:082023-05-04 23:02:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-04 23:02:12]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3316kb
  • [2023-05-04 23:02:08]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define For(x, y, z) for(int x = (y); x <= (z); x++)
#define Rep(x, y, z) for(int x = (y); x >= (z); x--)
using namespace std;
const int MAXN = 1e3 + 5;
char buf[1 << 12], *pp1 = buf, *pp2 = buf, nc;
inline char gc() {
    return (pp1 == pp2) && (pp2 = (pp1 = buf) + fread(buf, 1, 1 << 12, stdin), pp1 == pp2) ? EOF : *pp1++;
}
inline int read() {
    int x = 0, ny = 1;
    for(; nc = gc(), (nc < 48 || nc > 57) && nc != EOF; ) 
        if(nc == '-') ny = -1;
    if(nc < 0) return nc;
    x = nc ^ 48;
    for(; nc = gc(), (nc >= 48 && nc <= 57 && nc != EOF); )
        x = (x << 3) + (x << 1) + (nc ^ 48);
    return x * ny;
}
int n, m, ans[MAXN][MAXN], s[4][4] = {{1, 0, 1, 1}, {0, 1, 1, 1}, {1, 1, 0, 1}, {1, 1, 1, 0}};
int ss[4][4] = {{0, 0, 1, 0}, {0, 1, 1, 1}, {1, 1, 0, 1}, {0, 1, 1, 1}};
void Solve() {
    n = read(), m = read();
    int cnt = 0;
    if((n == 2 && m == 2) || (n == 2 && m == 3) || (n == 3 && m == 2) || (n == 3 && m == 3)) {
        For(i, 1, n) For(j, 1, m) ans[i][j] = 1, cnt++;
    } else if(n == 3 || m == 3) {
        For(i, 1, n) For(j, 1, m) ans[i][j] = ss[i % 4][j % 4], cnt += ans[i][j];
    }
    else {
        For(i, 1, n) For(j, 1, m) 
            ans[i][j] = s[i % 4][j % 4], cnt += ans[i][j];
    }
    cout << cnt << '\n';
    For(i, 1, n) {
        For(j, 1, m) cout << ans[i][j] << ' ';
        cout << '\n';
    }
}
int main() {
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    for(int t = read(); t--; ) {
        Solve();
    }     
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3316kb

input:

3
2 2
3 4
3 8

output:

4
1 1 
1 1 
9
1 1 1 0 
1 0 1 1 
1 1 1 0 
18
1 1 1 0 1 1 1 0 
1 0 1 1 1 0 1 1 
1 1 1 0 1 1 1 0 

result:

wrong answer Length must be equal to m (test case 1)