QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#809829 | #9874. Matrix Construction | ucup-team191# | Compile Error | / | / | C++23 | 862b | 2024-12-11 17:35:54 | 2024-12-11 17:36:19 |
Judging History
answer
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1e3 + 50;
int A[N][N], n, m;
bool check() {
vector < int > S;
for(int i = 0;i < n;i++) {
for(int j = 0;j < m;j++) {
if(i + 1 < n) S.push_back(A[i][j] + A[i + 1][j]);
if(j + 1 < m) S.push_back(A[i][j] + A[i][j + 1]);
}
}
sort(S.begin(), S.end());
for(int i = 0;i + 1 < (int)S.size();i++)
if(S[i] == S[i + 1]) return false;
return true;
}
int main() {
int T; scanf("%d", &T);
for(;T--;) {
scanf("%d%d", &n, &m);
int cnt = 1;
for(int dig = 0;dig <= (n + m) - 2;dig++) {
for(int i = 0;i < n;i++) {
if(dig - i >= 0 && dig - i < m) {
A[i][dig - i] = cnt++;
}
}
}
printf("YES\n");
for(int i = 0;i < n;i++) {
for(int j = 0;j < m;j++) {
printf("%d ", A[i][j]);
}
printf("\n");
}
}
}
详细
answer.code: In function ‘bool check()’: answer.code:11:9: error: ‘vector’ was not declared in this scope 11 | vector < int > S; | ^~~~~~ answer.code:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’? 2 | #include <algorithm> +++ |+#include <vector> 3 | answer.code:11:18: error: expected primary-expression before ‘int’ 11 | vector < int > S; | ^~~ answer.code:14:39: error: ‘S’ was not declared in this scope 14 | if(i + 1 < n) S.push_back(A[i][j] + A[i + 1][j]); | ^ answer.code:15:39: error: ‘S’ was not declared in this scope 15 | if(j + 1 < m) S.push_back(A[i][j] + A[i][j + 1]); | ^ answer.code:18:14: error: ‘S’ was not declared in this scope 18 | sort(S.begin(), S.end()); | ^ answer.code: In function ‘int main()’: answer.code:25:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | int T; scanf("%d", &T); | ~~~~~^~~~~~~~~~ answer.code:27:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%d%d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~