Task: | Grid Sort |
Sender: | htoik |
Submission time: | 2024-11-27 17:39:15 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.00 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.00 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.00 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | ACCEPTED | 0.00 s | details |
#32 | ACCEPTED | 0.04 s | details |
#33 | ACCEPTED | 0.01 s | details |
#34 | ACCEPTED | 0.01 s | details |
#35 | ACCEPTED | 0.01 s | details |
#36 | ACCEPTED | 0.01 s | details |
#37 | ACCEPTED | 0.04 s | details |
#38 | ACCEPTED | 0.01 s | details |
#39 | ACCEPTED | 0.01 s | details |
#40 | ACCEPTED | 0.01 s | details |
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; int main(){ ios::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; vector<vector<ll>> xs; xs.reserve(n); for(int y=0; y<n; y++){ vector<ll> row; row.reserve(n); for(int i=0; i<n; i++){ ll x; cin >> x; row.push_back(x); } xs.push_back(row); } // for(int i=0; i<n; i++){ // sort(xs[i].begin(), xs[i].end()); // } vector<pair<ll,int>> sortrow; for(int i=0; i<n; i++){ sortrow.push_back({xs[0][i], i}); } sort(sortrow.begin(), sortrow.end(), [](const auto& a, const auto& b){ return a.first < b.first; }); // for(int i=0; i<n; i++){ // cout << "Push: " << sortrow[i].first << " " << sortrow[i].second << "\n"; // } for(int y=0; y<n; y++){ vector<ll> r2 = xs[y]; // cout << "Row: " << y << "\n"; for(int i=0; i<n; i++){ r2[i] = xs[y][sortrow[i].second]; // cout << r2[i] << " " << i << " " << sortrow[i].second << " " << y << "\n"; } // cout << "\n"; xs[y] = r2; // cout << "this: " << y << "\n"; // for(int i=0; i<n; i++){ // cout << i << ": " << xs[y][i] << "\n"; // } } // for(int y=0; y<n; y++){ // for(int x=0; x<n; x++){ // cout << xs[y][x] << " "; // } // cout << "\n"; // } sort(xs.begin(), xs.end(), [](const auto& a, const auto& b){ return a[0] < b[0]; }); for(int y1=0; y1<n; y1++){ for(int x1=0; x1<n; x1++){ for(int y2=y1; y2<n; y2++){ for(int x2=x1; x2<n; x2++){ if(!(x1 < x2 ? (xs[y1][x1] < xs[y2][x2]) : (y1 < y2 ? (xs[y1][x1] < xs[y2][x2]) : true))){ cout << "No\n"; return 0; } } } } } cout << "Yes\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 1 |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 2
Verdict: ACCEPTED
input |
---|
2 4 3 2 1 |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 3
Verdict: ACCEPTED
input |
---|
2 4 1 3 2 |
correct output |
---|
No |
user output |
---|
No |
Test 4
Verdict: ACCEPTED
input |
---|
2 1 3 4 2 |
correct output |
---|
No |
user output |
---|
No |
Test 5
Verdict: ACCEPTED
input |
---|
3 7 8 9 1 2 3 4 5 6 |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 6
Verdict: ACCEPTED
input |
---|
3 1 7 3 2 4 9 8 6 5 |
correct output |
---|
No |
user output |
---|
No |
Test 7
Verdict: ACCEPTED
input |
---|
3 4 6 5 7 9 8 1 3 2 |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 8
Verdict: ACCEPTED
input |
---|
3 3 6 2 7 5 1 8 4 9 |
correct output |
---|
No |
user output |
---|
No |
Test 9
Verdict: ACCEPTED
input |
---|
3 6 5 4 3 2 1 9 8 7 |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 10
Verdict: ACCEPTED
input |
---|
3 9 7 8 3 1 2 6 4 5 |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 11
Verdict: ACCEPTED
input |
---|
3 2 1 3 8 7 9 5 4 6 |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 12
Verdict: ACCEPTED
input |
---|
3 2 1 3 8 7 9 5 4 6 |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 13
Verdict: ACCEPTED
input |
---|
4 6 8 13 11 3 15 16 4 7 5 1 12 2 9 14 10 |
correct output |
---|
No |
user output |
---|
No |
Test 14
Verdict: ACCEPTED
input |
---|
4 1 4 2 3 5 8 6 7 9 12 10 11 13 16 14 15 |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 15
Verdict: ACCEPTED
input |
---|
4 12 11 9 10 16 15 13 14 8 7 5 6 4 3 1 2 |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 16
Verdict: ACCEPTED
input |
---|
5 10 16 19 2 15 5 18 24 13 9 4 14 23 1 11 21 8 17 6 22 ... |
correct output |
---|
No |
user output |
---|
No |
Test 17
Verdict: ACCEPTED
input |
---|
5 5 15 22 19 18 25 21 3 4 13 14 16 1 12 20 6 7 24 17 23 ... |
correct output |
---|
No |
user output |
---|
No |
Test 18
Verdict: ACCEPTED
input |
---|
5 12 4 2 25 13 9 21 24 5 19 3 23 16 7 6 17 15 11 14 1 ... |
correct output |
---|
No |
user output |
---|
No |
Test 19
Verdict: ACCEPTED
input |
---|
10 23 5 38 47 41 71 26 67 58 56 78 90 54 49 1 10 92 34 72 16 15 11 8 64 65 40 2 6 9 63 18 24 14 29 55 7 27 19 39 48 ... |
correct output |
---|
No |
user output |
---|
No |
Test 20
Verdict: ACCEPTED
input |
---|
10 26 28 36 64 47 85 75 11 20 25 35 24 84 9 76 89 67 23 95 48 74 87 31 46 99 72 8 44 69 34 58 82 56 79 3 62 92 4 12 51 ... |
correct output |
---|
No |
user output |
---|
No |
Test 21
Verdict: ACCEPTED
input |
---|
10 86 96 43 88 95 21 4 31 16 91 77 87 69 6 2 22 100 28 20 68 52 64 70 66 99 23 44 11 38 27 80 67 62 56 13 15 5 29 98 78 ... |
correct output |
---|
No |
user output |
---|
No |
Test 22
Verdict: ACCEPTED
input |
---|
10 86 57 3 17 90 42 35 79 63 44 30 96 7 2 82 66 47 25 5 12 54 15 4 67 1 68 24 89 62 14 97 29 65 39 31 84 43 80 38 78 ... |
correct output |
---|
No |
user output |
---|
No |
Test 23
Verdict: ACCEPTED
input |
---|
10 5 99 63 18 74 50 47 72 30 39 6 84 41 1 40 73 7 81 52 31 20 82 34 2 68 42 10 87 19 25 36 67 79 4 53 75 26 95 69 77 ... |
correct output |
---|
No |
user output |
---|
No |
Test 24
Verdict: ACCEPTED
input |
---|
10 63 79 22 48 30 86 25 71 57 47 14 90 26 70 15 33 55 91 75 49 64 4 13 81 38 24 10 11 97 87 84 89 40 23 9 96 66 1 68 7 ... |
correct output |
---|
No |
user output |
---|
No |
Test 25
Verdict: ACCEPTED
input |
---|
10 63 66 64 70 65 61 62 68 69 67 43 46 44 50 45 41 42 48 49 47 3 6 4 10 5 1 2 8 9 7 73 76 74 80 75 71 72 78 79 77 ... |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 26
Verdict: ACCEPTED
input |
---|
10 10 47 74 89 100 25 93 79 7 3 43 29 12 70 17 92 5 34 35 88 71 28 80 16 36 94 62 75 33 44 87 14 86 27 42 39 52 4 77 50 ... |
correct output |
---|
No |
user output |
---|
No |
Test 27
Verdict: ACCEPTED
input |
---|
10 12 59 65 54 5 48 30 62 98 68 51 90 9 4 52 32 47 17 64 41 15 42 79 61 35 19 95 67 22 44 84 6 40 25 33 75 34 91 99 88 ... |
correct output |
---|
No |
user output |
---|
No |
Test 28
Verdict: ACCEPTED
input |
---|
10 26 27 28 29 25 23 22 24 21 30 86 87 88 89 85 83 82 84 81 90 56 57 58 59 55 53 52 54 51 60 16 17 18 19 15 13 12 14 11 20 ... |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 29
Verdict: ACCEPTED
input |
---|
10 76 71 72 77 75 73 80 74 78 79 26 21 22 27 25 23 30 24 28 29 56 51 52 57 55 53 60 54 58 59 66 61 62 67 65 63 70 64 68 69 ... |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 30
Verdict: ACCEPTED
input |
---|
10 28 25 23 29 27 21 26 30 22 24 78 75 73 79 77 71 76 80 72 74 88 85 83 89 87 81 86 90 82 84 68 65 63 69 67 61 66 70 62 64 ... |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 31
Verdict: ACCEPTED
input |
---|
10 77 74 71 72 75 80 79 76 78 73 17 14 11 12 15 20 19 16 18 13 67 64 61 62 65 70 69 66 68 63 7 4 1 2 5 10 9 6 8 3 ... |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 32
Verdict: ACCEPTED
input |
---|
100 1598 1520 1534 1501 1563 1599 ... |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 33
Verdict: ACCEPTED
input |
---|
100 6303 2749 9513 2663 1635 7785 ... |
correct output |
---|
No |
user output |
---|
No |
Test 34
Verdict: ACCEPTED
input |
---|
100 2262 7066 4010 8234 3186 9889 ... |
correct output |
---|
No |
user output |
---|
No |
Test 35
Verdict: ACCEPTED
input |
---|
100 8560 6500 1040 9851 4125 4121 ... |
correct output |
---|
No |
user output |
---|
No |
Test 36
Verdict: ACCEPTED
input |
---|
100 1726 828 4131 4947 8086 3937 5... |
correct output |
---|
No |
user output |
---|
No |
Test 37
Verdict: ACCEPTED
input |
---|
100 8374 8365 8332 8364 8306 8320 ... |
correct output |
---|
Yes |
user output |
---|
Yes |
Test 38
Verdict: ACCEPTED
input |
---|
100 6651 31 6880 1696 1066 2571 32... |
correct output |
---|
No |
user output |
---|
No |
Test 39
Verdict: ACCEPTED
input |
---|
100 2248 9395 3367 8837 4304 5331 ... |
correct output |
---|
No |
user output |
---|
No |
Test 40
Verdict: ACCEPTED
input |
---|
100 9289 3706 8940 6173 7120 6781 ... |
correct output |
---|
No |
user output |
---|
No |