QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#218512#6743. water235retr0Compile Error//C++14677b2023-10-18 14:19:502023-10-18 14:19:51

Judging History

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

  • [2023-10-18 14:19:51]
  • 评测
  • [2023-10-18 14:19:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    int ans = 1;
    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i == j) a[i][j] = 1, ans++;
        }
    }
    if(n != m) {
        if(n > m) {
            a[n - 1][0] = 1;
            ans++;
        }
        if(n < m) {
            a[0][m - 1] = 1;
            ans++
        }
    }
    cout << ans << '\n';
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cout << a[i][j] << " ";
        }
        cout << '\n';
    }
    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:20:18: error: expected ‘;’ before ‘}’ token
   20 |             ans++
      |                  ^
      |                  ;
   21 |         }
      |         ~