QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212599 | #3860. Drone Photo | aris | WA | 132ms | 29548kb | C++14 | 1.2kb | 2023-10-13 17:57:10 | 2023-10-13 17:57:11 |
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;
}
}
int 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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3440kb
input:
2 1 3 4 2
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
2 3 2 4 1
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
3 9 2 4 1 5 3 7 8 6
output:
6
result:
ok single line: '6'
Test #4:
score: -100
Wrong Answer
time: 132ms
memory: 29548kb
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:
-929806172
result:
wrong answer 1st lines differ - expected: '1263938062500', found: '-929806172'