QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#212600 | #3860. Drone Photo | aris | AC ✓ | 294ms | 29700kb | C++14 | 1.2kb | 2023-10-13 17:58:14 | 2023-10-13 17:58:14 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int ages[1505][1505];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> ages[i][j];
}
}
vector<int> less_in_row(n*n + 1);
vector<int> less_in_col(n*n + 1);
for (int i = 0; i < n; i++) {
vector<int> curr_row(n);
for (int j = 0; j < n; j++) {
curr_row[j] = ages[i][j];
}
sort(curr_row.begin(), curr_row.end());
for (int i = 0; i < n; i++) {
less_in_row[curr_row[i]] = i;
}
}
for (int j = 0; j < n; j++) {
vector<int> curr_col(n);
for (int i = 0; i < n; i++) {
curr_col[i] = ages[i][j];
}
sort(curr_col.begin(), curr_col.end());
for (int i = 0; i < n; i++) {
less_in_col[curr_col[i]] = i;
}
}
ll sum = 0;
for (int k = 1; k <= n*n; k++) {
sum += (less_in_row[k]*(n - 1 - less_in_col[k]) + less_in_col[k]*(n - 1 - less_in_row[k]));
}
sum /= 2;
cout << sum;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
2 1 3 4 2
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
2 3 2 4 1
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
3 9 2 4 1 5 3 7 8 6
output:
6
result:
ok single line: '6'
Test #4:
score: 0
Accepted
time: 139ms
memory: 29636kb
input:
1500 2248501 2248502 2248503 2248504 2248505 2248506 2248507 2248508 2248509 2248510 2248511 2248512 2248513 2248514 2248515 2248516 2248517 2248518 2248519 2248520 2248521 2248522 2248523 2248524 2248525 2248526 2248527 2248528 2248529 2248530 2248531 2248532 2248533 2248534 2248535 2248536 2248537...
output:
1263938062500
result:
ok single line: '1263938062500'
Test #5:
score: 0
Accepted
time: 138ms
memory: 29464kb
input:
1499 2247001 2245502 2242505 2242504 2241005 2239506 2238007 2236508 2235009 2233510 2232011 2230512 2229013 2227514 2226015 2224516 2223017 2221518 2220019 2079113 2211025 2215522 2214023 2212524 2217021 2209526 2208027 2206528 2205029 2203530 2202031 2200532 2199033 2197534 2196035 2194536 2193037...
output:
1237639616078
result:
ok single line: '1237639616078'
Test #6:
score: 0
Accepted
time: 130ms
memory: 29564kb
input:
1500 2248501 2247001 2245501 2244001 2242501 2181001 2239501 2238001 2236501 2235001 2233501 2232001 2230501 2229001 2227501 2226001 2224501 2223001 2221501 2220001 2218501 2217001 2215501 2214001 2212501 2211001 2209501 2208001 2206501 2205001 2203501 2202001 2200501 2199001 2197501 2196001 2194501...
output:
1263864653932
result:
ok single line: '1263864653932'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
2 2 1 4 3
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 31ms
memory: 8064kb
input:
500 98385 2209 73901 62830 109771 156465 246882 100403 203031 116661 75939 18177 161380 207027 74136 167721 187703 120443 127071 98894 5209 61624 187062 86977 88581 115114 167657 60246 233371 31844 189984 209184 248558 36050 244251 140478 161331 185453 41727 125284 118405 151906 131643 64183 91178 1...
output:
10374282899
result:
ok single line: '10374282899'
Test #9:
score: 0
Accepted
time: 292ms
memory: 29616kb
input:
1500 1325678 1423672 1889031 262212 363747 355567 132826 634046 2211541 1236130 1391581 1168021 708925 1309521 363352 1208748 1023128 2029396 1524939 613341 959252 41827 206731 1388854 2195436 2064215 622706 1121313 825049 360021 1443155 615388 249971 1227544 6033 2007227 310725 1919606 554227 29258...
output:
842632564705
result:
ok single line: '842632564705'
Test #10:
score: 0
Accepted
time: 294ms
memory: 29536kb
input:
1499 1228161 2106486 2151651 708102 270437 1640023 1830663 1178040 969988 397189 1858052 1291397 2136020 130574 895186 2101390 2244480 1136533 798189 1010546 721509 810126 1017483 1571912 760642 641402 947358 121367 430471 299474 128934 259312 1032545 127697 342257 1315317 487370 862201 1184679 2212...
output:
840374658273
result:
ok single line: '840374658273'
Test #11:
score: 0
Accepted
time: 138ms
memory: 29624kb
input:
1500 1500 3000 4500 6000 7500 9000 10500 12000 13500 15000 16500 18000 19500 21000 22500 24000 25500 27000 28500 30000 31500 33000 34500 36000 37500 39000 40500 42000 43500 45000 46500 48000 49500 51000 52500 54000 55500 57000 58500 60000 61500 63000 64500 66000 67500 69000 70500 72000 73500 75000 7...
output:
1263938062500
result:
ok single line: '1263938062500'
Test #12:
score: 0
Accepted
time: 137ms
memory: 29700kb
input:
1499 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
1260569673414
result:
ok single line: '1260569673414'