Блог пользователя wlzhouzhuan

Автор wlzhouzhuan, история, 3 года назад, По-английски

Hello, codeforces! I don't think the interactor of CF1557E is smart enough. Many wrong codes can get Accepted.

First, the hack input format in CF1557E is:

T
x[1] y[1]
x[2] y[2]
...
x[T] y[T]

As you see, we can only input the coordinate of the King, but the King's route is by interactor.

So I have no way to hack it, but to post a blog to say it.

Take my code as an example: https://codeforces.com/contest/1557/submission/125431623 .

It's not correct, and it can be easily hacked.

Here is my Hand Player , which you can control the King's route (use Windows) :

// Author: wlzhouzhuan
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fir first
#define sec second
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, t) memset(s, t, sizeof(s))
#define mcpy(s, t) memcpy(s, t, sizeof(t))
#define poly vector<int>
#define SZ(x) (int(x.size()))
template<typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> void ckmax(T1 &a, T2 b) { if (a < b) a = b; }
int read() {
  int x = 0, f = 0; char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();
  return f ? -x : x;
}
template<typename T> void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template<typename T> void print(T x, char let) {
  print(x), putchar(let);
}

vector<pii> vec;
bool ban[10][10];
int Qx, Qy;
int Kx, Ky;

int main() {
  Qx = Qy = 1;
  Kx = 4, Ky = 4;
  int times = 131;
  while (times--) {
    system("cls");
    for (int i = 1; i <= 8; i++) {
      for (int j = 1; j <= 8; j++) {
        if (i == Qx && j == Qy) {
          printf("Q "); 
          ban[i][j] = 0;
        } else if (i == Kx && j == Ky) {
          printf("K ");
          ban[i][j] = 0;
        } else if (i == Qx || j == Qy || abs(i - Qx) == abs(j - Qy)) {
          printf("# ");
          ban[i][j] = 1;
        } else {
          printf(". ");
          ban[i][j] = 0;
        }
      }
      puts("");
    }
    int tox, toy;
    cin >> tox >> toy;
    if (tox == -1) {
      for (auto v: vec) {
        printf("%d %d\n", v.fir, v.sec);
      }
      system("pause");
      continue;
    }
    if (ban[tox][toy]) {
      puts("Invalid!");
      system("pause");
      continue;
    }
    if (abs(tox - Kx) <= 1 && abs(toy - Ky) <= 1 && !(tox == Kx && toy == Ky)) {
      Kx = tox, Ky = toy;
      vec.pb({Kx, Ky});
    } else {
      puts("Invalid");
      system("pause");
      continue;
    }
    if (Qx & 1) Qy++;
    else Qy--;
    if (Qy > 8) Qx++, Qy = 8;
    if (Qy < 1) Qx++, Qy = 1;
    if (Qx > 8) Qx = 1; 
  }
  system("cls");
  for (auto v: vec) {
    printf("%d %d\n", v.fir, v.sec);
  }
  return 0;
}

I made the hack by hand (130+ steps, and the King still alive):

4 4
4 3
5 4
5 5
5 6
5 7
5 8
6 8
6 7
6 6
6 5
5 4
5 3
5 2
6 2
5 3
4 4
4 5
5 5
5 4
5 3
5 2
4 2
4 3
4 4
3 4
2 4
1 5
2 6
2 7
2 8
2 7
2 6
2 5
2 4
3 4
3 3
3 2
3 3
3 4
3 5
3 6
2 6
2 7
2 8
3 8
3 7
3 6
3 5
3 4
3 3
3 2
3 1
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 6
4 5
4 4
4 3
5 3
5 2
5 1
4 1
5 1
4 1
4 2
4 3
4 4
3 4
4 4
5 5
5 6
5 5
5 4
4 5
3 5
2 5
1 5
1 4
1 3
1 2
2 3
2 4
2 5
1 6
2 6
2 7
2 8
2 7
2 6
2 5
2 4
2 3
3 3
3 2
3 1
3 2
3 3
3 4
3 5
3 6
4 6
4 7
4 8
4 7
4 6
4 5
4 4
4 3
5 3
5 2
5 1
5 2
5 3
5 4
5 5
5 6
6 6
6 7
6 8
6 7
6 6
6 5
6 4
6 5
6 4
5 4

So I think writers should change the interactor's strategy to avoid the incorrect code gets Accepted.

What's your opinion about it ?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +500
  • Проголосовать: не нравится