QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103278#6309. AqreNerovix#WA 2ms3400kbC++202.2kb2023-05-04 23:18:022023-05-04 23:18:04

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:18:04]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3400kb
  • [2023-05-04 23:18:02]
  • 提交

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 = 1100;
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 + 10) For(j, 1, m + 10) ans[i][j] = ss[i % 4][j % 4], cnt += ans[i][j];
    }
    else {
        For(i, 1, n + 10) For(j, 1, m + 10) 
            ans[i][j] = s[i % 4][j % 4], cnt += ans[i][j];
    }
    int mx = cnt, px = 0, py = 0;
    for(int x_ = 0; x_ < 4; x_++)
        for(int y_ = 0; y_ < 4; y_++) {
            cnt = 0;
            for(int i = 1; i <= n; i++)
                for(int j = 1; j <= m; j++)
                    cnt += ans[x_ + i][y_ + j];
            if(cnt > mx) {
                mx = cnt;
                px = x_, py = y_;
            }
        }
    cout << mx << '\n';
    For(i, 1, n) {
        For(j, 1, m) cout << ans[px + i][py + 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: 3400kb

input:

3
2 2
3 4
3 8

output:

4
1 1 
1 1 
119
1 1 1 0 
1 0 1 1 
1 1 1 0 
152
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)