Submission details
Task:Hypyt
Sender:ArktinenKarpalo
Submission time:2025-10-17 22:53:38 +0300
Language:C++ (C++17)
Status:READY
Result:30
Feedback
groupverdictscore
#1ACCEPTED30
#20
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2details
#2ACCEPTED0.01 s1, 2details
#3--2details
#4--2details
#5--2details

Code

#include <bits/stdc++.h>
using namespace std;
typedef vector<bitset<55>> VK;
typedef vector<bitset<222>> VS;
typedef vector<pair<int, int>> VA;

bool hau(int x, int y, int n, int m, VS &siirtyma, VK &kautu, VA &A) {
  bool ok = true;
  vector<pair<int, pair<int, int>>> W;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (kautu[i][j])
        continue;
      ok = false;
      if (siirtyma[i - x + 50][j - y + 50])
        continue;
      W.push_back({max(abs(i - x), abs(j - y)), {i, j}});
    }
  }
  sort(W.rbegin(), W.rend());
  for (auto &u : W) {
    int i = u.second.first;
    int j = u.second.second;
    siirtyma[i - x + 50][j - y + 50] = 1;
    kautu[i][j] = 1;
    if (hau(i, j, n, m, siirtyma, kautu, A)) {
      A.push_back({i - x, j - y});
      return true;
    }
    kautu[i][j] = 0;
    siirtyma[i - x + 50][j - y + 50] = 0;
  }
  if (ok) {
    return true;
  }
  return false;
}

void solve(int n, int m) {
  VS siirtyma(222);
  VK kautu(55);
  VA a;
  kautu[0][0] = 1;
  hau(0, 0, n, m, siirtyma, kautu, a);
  reverse(a.begin(), a.end());
  for (auto u : a)
    cout << u.first << " " << u.second << "\n";
}

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    solve(n, m);
  }
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
25
1 1
1 2
1 3
1 4
...

correct output
0 1
0 2
0 -1
0 3
0 -2
...

user output
0 1
0 2
0 -1
0 3
0 -2
...

Test 2

Group: 1, 2

Verdict: ACCEPTED

input
100
5 5
5 5
5 5
5 5
...

correct output
4 4
-4 -3
4 2
-4 -1
4 0
...

user output
4 4
0 -4
-1 4
-1 -4
0 4
...

Test 3

Group: 2

Verdict:

input
100
1 25
20 40
5 34
50 34
...

correct output
0 24
0 -23
0 22
0 -21
0 20
...

user output
(empty)

Test 4

Group: 2

Verdict:

input
100
46 47
41 39
46 36
46 30
...

correct output
45 46
-45 -45
45 44
-45 -43
45 42
...

user output
(empty)

Test 5

Group: 2

Verdict:

input
100
50 50
50 50
50 50
50 50
...

correct output
49 49
-49 -48
49 47
-49 -46
49 45
...

user output
(empty)