QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#660066 | #7878. Matrix Distances | sh-sho1kat | WA | 0ms | 3540kb | C++20 | 1.6kb | 2024-10-20 04:25:35 | 2024-10-20 04:25:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// 2024-10-20 01:55:02
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod 1000000007
#define inf (1LL << 62)
#define all(x) x.begin(), x.end(), greater<ll>()
#define eb push_back
#define ff first
#define ss second
#define yes cout << "YES" << nl
#define no cout << "NO" << nl
#define dtob(bits, n) bitset<bits>(n).to_string()
#define btod(bin) stoll(bin, nullptr, 2)
#define ok cout << "Eureka" << nl
#define nl '\n'
#define SH 0
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpll;
int main()
{
fastio;
ll n, m;
cin >> n >> m;
ll a[n + 5][m + 5];
map<ll, ll> mp;
ll cnt = 0;
for (ll i = 1; i <= n; i++)
{
for (ll j = 1; j <= m; j++)
{
ll p;
cin >> p;
if (!mp[p])
mp[p] = ++cnt;
a[i][j] = mp[p];
}
}
for (ll i = 1; i <= n; i++)
{
for (ll j = 1; j <= m; j++)
{
cout << a[i][j] << " ";
}
cout << nl;
}
vl v1[cnt + 5], v2[cnt + 5];
for (ll i = 1; i <= n; i++)
for (ll j = 1; j <= m; j++)
v1[a[i][j]].eb(i), v2[a[i][j]].eb(j);
ll sum = 0;
for (ll i = 1; i <= cnt; i++)
{
sort(all(v1[i]));
sort(all(v2[i]));
ll p = v1[i].size();
--p;
for (ll j = 0; j < v1[i].size(); j++)
{
sum += p * v1[i][j];
sum += p * v2[i][j];
p -= 2;
}
}
cout << sum*2 << nl;
return SH;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3540kb
input:
2 2 1 1 2 2
output:
1 1 2 2 4
result:
wrong answer 1st numbers differ - expected: '4', found: '1'