QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#689137#3836. So I'll Max Out My Constructive Algorithm SkillsnageingWA 1ms3616kbC++201.0kb2024-10-30 15:30:512024-10-30 15:30:52

Judging History

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

  • [2024-10-30 15:30:52]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3616kb
  • [2024-10-30 15:30:51]
  • 提交

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 ++;
			}
		}	
	}
	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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

input:

1
2
4 3
2 1

output:

4 3 1 2

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3492kb

input:

100
9
30 75 35 51 25 19 76 65 62
11 56 63 60 77 48 28 26 74
16 44 46 41 17 8 66 61 42
29 7 43 38 40 31 27 10 39
52 23 58 80 50 20 33 69 47
79 1 5 49 22 37 71 18 70
54 72 4 64 55 34 12 6 15
14 53 45 13 32 59 73 57 81
36 3 78 24 2 68 9 67 21
7
11 28 2 19 9 41 24
17 34 5 10 42 18 47
33 35 22 8 49 1 29
...

output:

21 67 9 68 2 24 78 3 36 14 53 45 13 32 59 73 57 81 15 6 12 34 55 64 4 72 54 79 1 5 49 22 37 71 18 70 47 69 33 20 50 80 58 23 52 29 7 43 38 40 31 27 10 39 42 61 66 8 17 41 46 44 16 11 56 63 60 77 48 28 26 74 62 65 76 19 25 51 35 75 30
11 28 2 19 9 41 24 47 18 42 10 5 34 17 33 35 22 8 49 1 29 26 7 44 ...

result:

wrong answer [case 1] Not lazy, up = 43, down = 37