QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#152514#6309. Aqrechen_zexingCompile Error//C++172.3kb2023-08-28 10:54:052023-08-28 10:54:07

Judging History

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

  • [2023-08-28 10:54:07]
  • 评测
  • [2023-08-28 10:54:05]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int a[1005][1005];
int main() {
    int T = 1, kase = 0;
    cin >> T;
    while (T--) {
        int n, m;
        cin >> n >> m;
        if (n <= 3 && m <= 3) {
            printf("%d\n", n * m);
            for (int i = 1; i <= n; i++, puts(""))
                for (int j = 1; j <= m; j++)
                    printf("1");
        }
        else if (n == 3) {
            int ans=m/4*9+m%4*3-(m%4>1);
            printf("%d\n",ans);
            for(int i=1;i<=n;i++,puts(""))
                for(int j=1;j<=m;j++){
                    if(j%4==2&&i==3||j%4==0&&i!=3) printf("0");
                    else printf("1");
                }
        }
        else if (m == 3) {
            int ans=n/4*9+n%4*3-(n%4>1);
            printf("%d\n",ans);
            for(int i=1;i<=n;i++,puts(""))
                for(int j=1;j<=m;j++){
                    if(i%4==2&&j==3||i%4==0&&j!=3) printf("0");
                    else printf("1");
                }
        }
        else {
            int ans = 0;
            for (int i = 1; i <= n; i++) {
                if (i % 4 == 1) ans += m / 4 * 3 + m % 4;
                else if (i % 4 == 2) ans += m / 4 * 3 + m % 4 - (m % 4 > 1);
                else if (i % 4 == 3) ans += m / 4 * 3 + m % 4 - (m % 4 > 2);
                else ans += m / 4 * 3 + m % 4 - (m%4>0);
            }
            printf("%d\n", ans);
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= m; j++) {
                    if (i % 4 == 1 && j % 4 == 0 || i % 4 == 2 && j % 4 == 2 || i % 4 == 3 && j % 4 == 3 ||
                        i % 4 == 0 && j % 4 == 1)
                        a[i][j]=0;
                    else a[i][j]=1; 
                }
            if(n%4==1&&m%4==1){
                for(int i=2;i<=n;i+=4)
                    for(int j=1;j<=m;j++){
                        int ov=a[i][j];
                        a[i][j]=a[i+1][j],a[i+1][j]=a[i+2][j],a[i+2][j]=o;
                    }
            }
            for(int i=1;i<=n;i++,puts(""))
                for(int j=1;j<=m;j++)
                    printf("%d",a[i][j]);
        }
    }
    return 0;
}
/*
11101
11011
01110
10111
11101
 */


詳細信息

answer.code: In function ‘int main()’:
answer.code:55:73: error: ‘o’ was not declared in this scope; did you mean ‘ov’?
   55 |                         a[i][j]=a[i+1][j],a[i+1][j]=a[i+2][j],a[i+2][j]=o;
      |                                                                         ^
      |                                                                         ov