MiyanoShiho's blog

By MiyanoShiho, history, 3 years ago, In English

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 using same code 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:

Is there anybody who knows the reason?

THX :D

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By MiyanoShiho, history, 4 years ago, In English

Recently I wrote a fast read template and wanted to adapt it to multiple parameters.

The following is how I implemented it:

template <class T>
inline void read(T &x) {
  x = 0; int ch = getchar(); bool f = false;
  while (ch < '0' || ch > '9')
    ch = getchar(), f = (ch == '-') ? 1 : 0;
  while (ch >='0' && ch <='9')
    x = (x << 1) + (x << 3) + (ch ^ 48),
      ch = getchar();
  if (f) x = -x;
}

template <class T, class ...Args>
void read(T& x, Args... rest) {
  read(x), read(rest...);
}

However it completely crashed!

When I input 1 2 3 4, it just came out with 4 random int.

How should I improve that?

THX. XD

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By MiyanoShiho, history, 4 years ago, In English

I heard that we can change our names around the New Year, which will allow us to welcome 2021 with a fresh look.

However I don't find that option. I wonder will that be open this year? Or how can I do that?

Happy new year. Codeforces and Codeforcesers.

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it