QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#689145 | #3836. So I'll Max Out My Constructive Algorithm Skills | nageing | WA | 0ms | 3592kb | C++20 | 1.0kb | 2024-10-30 15:33:22 | 2024-10-30 15:33:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const int N = 2E5 + 10, mod = 1E9 + 7;
void solve() {
int n;
cin >> n;
vector a(n, vector<int>(n, 0));
for (int i = 0; i < n; i ++) {
for (int j = 0; j < n; j ++) {
cin >> a[i][j];
}
}
int cnt = 0;
vector<int> ans;
for (int i = 0, j; i < n; i ++) {
if (i % 2) {
ans.push_back(a[i][n - 1]);
j = n - 2;
while (j >= 0) {
if (a[i][j + 1] > a[i][j]) cnt ++;
ans.push_back(a[i][j]);
j --;
}
} else {
ans.push_back(a[i][0]);
j = 1;
while (j < n) {
if (a[i][j - 1] < a[i][j]) cnt ++;
ans.push_back(a[i][j]);
j ++;
}
}
}
cout << cnt << '\n';
if (cnt < n * n / 2) {
reverse(ans.begin(), ans.end());
}
for (int i = 0; i < n * n; i ++) {
cout << ans[i] << " \n"[i == n * n - 1];
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int t = 1;
cin >> t;
while (t --) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3592kb
input:
1 2 4 3 2 1
output:
0 2 1 3 4
result:
wrong answer Integer 0 violates the range [1, 4]