QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#521720 | #7042. So Easy | QFshengxiu# | WA | 1ms | 7844kb | C++20 | 2.5kb | 2024-08-16 14:09:49 | 2024-08-16 14:09:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define lowbit(x) (x & (-x))
#define all(x) x.begin(), x.end()
#define inf 0x3f3f3f3f3f3f3f3f
#define int long long
#define pai 3.14
#define QF ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define c1 cout << 1
#define c2 cout << 2
// #define width cout << ""
using ll = long long;
using PII = pair<int, int>;
using LD = long double;
mt19937_64 rnd(chrono::duration_cast<chrono::nanoseconds>(chrono::system_clock::now().time_since_epoch()).count());
constexpr int N = 1e3 + 10;
int a[N][N], row[N], col[N], b[N][N], c[N][N];
void solve()
{
int n;
cin >> n;
int rows, cols;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
cin >> a[i][j];
b[i][j] = a[i][j];
c[i][j] = a[i][j];
if (a[i][j] == -1)
{
rows = i;
cols = j;
}
}
}
int qrows = rows - 1;
if (rows == 1)
{
qrows += 2;
}
int mcols = 0, mrows = 0;
for (int i = 1; i <= n; i++)
{
if (i == cols)
continue;
int mi = inf;
for (int j = 1; j <= n; j++)
{
mi = min(mi, a[j][i]);
}
for (int j = 1; j <= n; j++)
{
b[j][i] -= mi;
}
}
int qcols = cols - 1;
if (cols == 1)
{
qcols += 2;
}
for (int i = 1; i <= n; i++)
{
if (i == rows)
continue;
int mi = inf;
for (int j = 1; j <= n; j++)
{
mi = min(mi, a[i][j]);
}
for (int j = 1; j <= n; j++)
{
c[i][j] -= mi;
}
}
int mi = inf;
for (int i = 1; i <= n; i++)
{
if (i == cols)
continue;
mi = min(b[qrows][i], mi);
}
for (int i = 1; i <= n; i++)
{
b[qrows][i] -= mi;
}
mi = inf;
for (int i = 1; i <= n; i++)
{
if (i == rows)
continue;
mi = min(c[i][qcols], mi);
}
for (int i = 1; i <= n; i++)
{
c[i][qcols] -= mi;
}
cout << b[qrows][cols] + c[rows][qcols] << endl;
}
signed main()
{
QF;
int T = 1;
// cin >> T;
for (int i = 1; i <= T; i++)
{
solve();
// cout << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7812kb
input:
3 1 2 1 0 -1 0 0 1 0
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 7844kb
input:
10 63 66 64 39 41 64 67 46 45 56 67 70 68 43 45 68 71 50 49 60 72 75 73 48 50 73 76 55 54 65 64 67 65 40 42 65 68 47 46 57 81 84 82 57 59 82 85 64 63 74 43 46 44 19 21 44 47 26 25 36 45 48 46 21 23 -1 49 28 27 38 70 73 71 46 48 71 74 53 52 63 57 60 58 33 35 58 61 40 39 50 81 84 82 57 59 82 85 64 63 74
output:
65
result:
wrong answer 1st numbers differ - expected: '46', found: '65'