I remember that once tourist got fst due to wrong compiler selected.
This time I got the same problem when I was doing 463C
I got accecpted with GNU G++17 7.3.0, but TLE with GNU G++17 9.2.0(64 bit, msys2)
The code is here
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for (int i = (int)(s); i <= (int)(t); ++ i)
#define deb(x) cout << #x << " = " << x << endl
#define ll long long
#define int long long
const int N = 2e3 + 10;
ll n, a[N][N];
ll l[N << 1], r[N << 1];
inline void solve() {
scanf("%lld", &n);
rep(i, 1, n) rep(j, 1, n)
scanf("%lld", &a[i][j]), l[i + j] += a[i][j], r[n + i - j] += a[i][j];
int x1, x2, y1, y2, val1 = -1, val2 = -1;
rep(i, 1, n) rep(j, 1, n) {
int val = l[i + j] + r[n + i - j] - a[i][j];
if ((i + j) & 1) {
if (val > val1) val1 = val, x1 = i, y1 = j;
} else {
if (val > val2) val2 = val, x2 = i, y2 = j;
}
}
printf("%lld\n", val1 + val2);
printf("%lld %lld\n%lld %lld", x1, y1, x2, y2);
}
signed main() {
int t = 1; //scanf("%d", &t);
while (t --) solve();
}
And the submissions are here:
- TLE: https://mirror.codeforces.com/contest/463/submission/121871272
- AC: https://mirror.codeforces.com/contest/463/submission/121817055
Is there anybody who knows the reason?
THX :D