QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#641914#8056. Travel 2maspyAC ✓232ms5512kbC++2011.9kb2024-10-15 03:16:512024-10-15 03:16:52

Judging History

你现在查看的是最新测评结果

  • [2024-10-15 03:16:52]
  • 评测
  • 测评结果:AC
  • 用时:232ms
  • 内存:5512kb
  • [2024-10-15 03:16:51]
  • 提交

answer

#line 1 "/home/maspy/compro/library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else

// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("Ofast,unroll-loops")
// いまの CF だとこれ入れると動かない?
// #pragma GCC target("avx2,popcnt")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'010'000'000;
template <>
constexpr ll infty<ll> = 2'020'000'000'000'000'000;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * 2'000'000'000'000'000'000;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;

using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...) \
  vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
int popcnt_mod_2(int x) { return __builtin_parity(x); }
int popcnt_mod_2(u32 x) { return __builtin_parity(x); }
int popcnt_mod_2(ll x) { return __builtin_parityll(x); }
int popcnt_mod_2(u64 x) { return __builtin_parityll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T>
T floor(T a, T b) {
  return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
  return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
  return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template <typename T, typename U>
T SUM(const vector<U> &A) {
  T sm = 0;
  for (auto &&a: A) sm += a;
  return sm;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

template <typename T>
T POP(deque<T> &que) {
  T a = que.front();
  que.pop_front();
  return a;
}
template <typename T>
T POP(pq<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(pqg<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(vc<T> &que) {
  T a = que.back();
  que.pop_back();
  return a;
}

template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
  if (check_ok) assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    (check(x) ? ok : ng) = x;
  }
  return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
  FOR(iter) {
    double x = (ok + ng) / 2;
    (check(x) ? ok : ng) = x;
  }
  return (ok + ng) / 2;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
  vc<int> A(S.size());
  FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
  return A;
}

template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
  vector<int> ids(len(A));
  iota(all(ids), 0);
  sort(all(ids), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  vc<T> B(len(I));
  FOR(i, len(I)) B[i] = A[I[i]];
  return B;
}

template <typename T, typename... Vectors>
void concat(vc<T> &first, const Vectors &... others) {
  vc<T> &res = first;
  (res.insert(res.end(), others.begin(), others.end()), ...);
}
#endif
#line 1 "/home/maspy/compro/library/other/io2.hpp"
#define INT(...)   \
  int __VA_ARGS__; \
  IN(__VA_ARGS__)
#define LL(...)   \
  ll __VA_ARGS__; \
  IN(__VA_ARGS__)
#define STR(...)      \
  string __VA_ARGS__; \
  IN(__VA_ARGS__)
#define CHR(...)    \
  char __VA_ARGS__; \
  IN(__VA_ARGS__)
#define DBL(...)           \
  long double __VA_ARGS__; \
  IN(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void read(int &a) { cin >> a; }
void read(long long &a) { cin >> a; }
void read(char &a) { cin >> a; }
void read(double &a) { cin >> a; }
void read(long double &a) { cin >> a; }
void read(string &a) { cin >> a; }
template <class T, class S>
void read(pair<T, S> &p) {
  read(p.first), read(p.second);
}
template <class T>
void read(vector<T> &a) {
  for (auto &i: a) read(i);
}
template <class T>
void read(T &a) {
  cin >> a;
}
void IN() {}
template <class Head, class... Tail>
void IN(Head &head, Tail &... tail) {
  read(head);
  IN(tail...);
}

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &A) {
  os << A.fi << " " << A.se;
  return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &A) {
  for (size_t i = 0; i < A.size(); i++) {
    if (i) os << " ";
    os << A[i];
  }
  return os;
}

// chatgpt helped me
class CoutInitializer {
public:
  CoutInitializer() { std::cout << std::fixed << std::setprecision(15); }
};
static CoutInitializer cout_initializer;

void print() {
  cout << "\n";
  cout.flush();
}

template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
  cout << head;
  if (sizeof...(Tail)) cout << " ";
  print(forward<Tail>(tail)...);
}

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 3 "main.cpp"

#line 2 "/home/maspy/compro/library/random/base.hpp"

u64 RNG_64() {
  static uint64_t x_
      = uint64_t(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count()) * 10150724397891781847ULL;
  x_ ^= x_ << 7;
  return x_ ^= x_ >> 9;
}

u64 RNG(u64 lim) { return RNG_64() % lim; }

ll RNG(ll l, ll r) { return l + RNG_64() % (r - l); }
#line 5 "main.cpp"

/*
木だと:戻ってしまったら進みなおす
dfsしたいのだが逆辺で戻るのが難しい

どの時点でもある点の入次数、出次数は釣り合っている
未知辺から訪れて未知辺から出られないのは1回までしか起こらない

双方向に辺をはったグラフは euler だということ
極大にすすむと始点に戻ってきて、始点は飽和する

dfs しながら、
・未知の辺があるならばサイクルを作る
・始点で未知の辺がなくなった状態で dfs の続き
*/

void solve() {
  vvc<int> TO;
  vvc<int> yet;
  vc<int> deg;
  vc<int> vis;

  map<pair<int, int>, int> MP;

#ifdef LOCAL
  vc<pair<int, int>> dat;
  int n = RNG(2, 6);
  FOR(v, 1, n) {
    int w = RNG(0, v);
    dat.eb(w, v);
  }
  FOR(RNG(0, 5)) {
    int a = RNG(0, n);
    int b = RNG(0, n);
    if (a < b) dat.eb(a, b);
  }
  UNIQUE(dat);
  vvc<int> god(n);
  for (auto& [a, b]: dat) { god[a].eb(b), god[b].eb(a); }
  int godv = RNG(0, n);
  print("n", n);
  FOR(v, n) print(v, ",", god[v]);
  print("godv", godv);
#endif

  int QLE = 0;
  auto ask = [&]() -> int {
    ++QLE;
#ifdef LOCAL
    int s = godv, d = len(god[godv]);
#else
    INT(s, d);
    --s;
#endif
    if (len(TO) <= s) TO.resize(s + 1), yet.resize(s + 1), deg.resize(s + 1), vis.resize(s + 1);
    if (TO[s].empty()) {
      TO[s].assign(d, -1);
      FOR(i, d) yet[s].eb(i);
      deg[s] = d;
    } else {
      assert(deg[s] == d);
    }
    return s;
  };

  auto out = [&](int i) -> void {
    print(">", 1 + i);
#ifdef LOCAL
    godv = god[godv][i];
#endif
  };

  auto dfs = [&](auto& dfs, int v, int p) -> void {
    // find cycle
    int a = v;
    while (1) {
      if (yet[a].empty()) {
        assert(a == v);
        break;
      }
      int i = POP(yet[a]);
      out(i);
      int b = ask();
      TO[a][i] = b;
      MP[mp(a, b)] = i;
      a = b;
    }
    int d = deg[v];
    FOR(i, d) {
      int w = TO[v][i];
      if (vis[w]) continue;
      out(i);
      assert(w == ask());
      vis[w] = 1;
      dfs(dfs, w, v);
    }
    if (p == -1) return;
    int i = MP[mp(v, p)];
    out(i);
    assert(ask() == p);
  };

  int s = ask();
  vis[s] = 1;
  dfs(dfs, s, -1);
  vc<int> ANS;
  FOR(a, len(TO)) {
    for (auto& b: TO[a]) {
      if (a < b) ANS.eb(1 + a), ANS.eb(1 + b);
    }
  }
  print("!", ANS);
#ifdef LOCAL
  vc<pair<int, int>> myans;
  FOR(a, len(TO)) {
    for (auto& b: TO[a]) {
      if (a < b) myans.eb(a, b);
    }
  }
  sort(all(myans));
  bool AC = (dat == myans) && (QLE <= 2 * (n + len(dat)));
  print("n=", n, "m=", len(dat), "QLE=", QLE);
  print("AC=", AC);
  assert(AC);
#else
  STR(S);
  assert(S == "Correct");
#endif
}

signed main() {
  INT(T);
  FOR(T) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3748kb

input:

2
1 1
2 1
1 1
2 1
1 1
Correct
1 3
4 2
2 2
4 2
1 3
3 1
1 3
2 2
1 3
2 2
4 2
2 2
1 3
3 1
1 3
Correct

output:

> 1
> 1
> 1
> 1
! 1 2
> 3
> 2
> 2
> 1
> 2
> 1
> 1
> 1
> 1
> 2
> 2
> 1
> 2
> 1
! 1 2 1 3 1 4 2 4

result:

ok correct! (2 test cases)

Test #2:

score: 0
Accepted
time: 149ms
memory: 3828kb

input:

1000
1 9
10 6
3 9
6 9
4 9
9 8
4 9
6 9
7 7
6 9
9 8
6 9
3 9
7 7
9 8
7 7
3 9
8 8
4 9
2 7
4 9
5 8
4 9
8 8
6 9
8 8
3 9
10 6
6 9
5 8
7 7
5 8
6 9
10 6
4 9
10 6
8 8
7 7
8 8
9 8
8 8
10 6
2 7
9 8
2 7
5 8
3 9
5 8
2 7
6 9
2 7
10 6
1 9
9 8
5 8
9 8
3 9
2 7
3 9
9 8
1 9
8 8
5 8
8 8
1 9
7 7
4 9
7 7
1 9
6 9
1 9
5 8
1...

output:

> 9
> 6
> 9
> 9
> 9
> 8
> 8
> 8
> 7
> 7
> 7
> 6
> 8
> 6
> 6
> 5
> 7
> 8
> 7
> 7
> 6
> 8
> 5
> 7
> 5
> 6
> 6
> 5
> 4
> 7
> 4
> 6
> 3
> 4
> 4
> 3
> 5
> 3
> 4
> 5
> 3
> 2
> 6
> 4
> 5
> 5
> 5
> 4
> 4
> 2
> 3
> 1
> 8
> 3
> 3
> 2
> 4
> 2
> 3
> 1
> 7
> 2
> 2
> 1
> 6
> 2
> 3
> 1
> 5
> 1
> 4
> 1
> 3
> 2
> 2
...

result:

ok correct! (1000 test cases)

Test #3:

score: 0
Accepted
time: 232ms
memory: 3560kb

input:

500
1 19
20 6
12 7
18 7
12 7
20 6
17 10
20 6
9 7
3 7
9 7
15 8
9 7
17 10
9 7
20 6
15 8
19 7
15 8
5 7
14 9
10 9
14 9
5 7
15 8
8 4
18 7
8 4
15 8
6 7
7 11
2 8
7 11
12 7
7 11
19 7
10 9
4 8
10 9
19 7
7 11
14 9
7 11
10 9
2 8
10 9
7 11
6 7
14 9
18 7
2 8
18 7
14 9
2 8
11 8
2 8
14 9
6 7
15 8
16 7
17 10
16 7
1...

output:

> 19
> 6
> 7
> 7
> 6
> 5
> 10
> 4
> 7
> 7
> 6
> 8
> 5
> 9
> 4
> 3
> 7
> 7
> 6
> 7
> 9
> 9
> 8
> 6
> 5
> 4
> 6
> 3
> 4
> 7
> 11
> 8
> 10
> 5
> 9
> 6
> 8
> 8
> 7
> 5
> 8
> 7
> 7
> 6
> 7
> 5
> 6
> 6
> 6
> 5
> 6
> 4
> 5
> 5
> 8
> 4
> 4
> 5
> 3
> 7
> 8
> 6
> 4
> 4
> 3
> 5
> 2
> 2
> 6
> 7
> 5
> 3
> 4
> 7
...

result:

ok correct! (500 test cases)

Test #4:

score: 0
Accepted
time: 193ms
memory: 3728kb

input:

100
1 99
100 4
29 11
100 4
8 8
72 8
8 8
57 5
8 8
9 9
71 8
9 9
8 8
82 7
23 6
82 7
29 11
82 7
8 8
100 4
55 9
75 10
84 5
75 10
21 4
75 10
16 7
75 10
55 9
41 7
55 9
76 9
33 5
52 6
93 10
26 10
93 10
52 6
46 6
52 6
33 5
76 9
55 9
96 10
24 10
62 12
97 8
62 12
24 10
96 10
49 5
92 13
49 5
67 10
49 5
96 10
42...

output:

> 99
> 4
> 11
> 3
> 8
> 8
> 7
> 5
> 6
> 9
> 8
> 8
> 5
> 7
> 6
> 6
> 10
> 5
> 4
> 2
> 9
> 10
> 5
> 9
> 4
> 8
> 7
> 7
> 8
> 7
> 7
> 9
> 5
> 6
> 10
> 10
> 9
> 5
> 6
> 4
> 4
> 8
> 6
> 10
> 10
> 12
> 8
> 11
> 9
> 9
> 5
> 13
> 4
> 10
> 3
> 8
> 5
> 7
> 4
> 4
> 7
> 3
> 7
> 7
> 6
> 2
> 3
> 10
> 9
> 11
> 8
> ...

result:

ok correct! (100 test cases)

Test #5:

score: 0
Accepted
time: 198ms
memory: 4508kb

input:

10
1 999
1000 10
80 7
1000 10
856 9
1000 10
485 11
675 7
662 10
675 7
485 11
466 6
485 11
867 5
485 11
1000 10
674 4
752 6
436 7
752 6
674 4
611 8
525 6
611 8
371 8
34 9
371 8
528 6
530 11
528 6
371 8
611 8
606 6
791 11
606 6
33 6
606 6
467 7
606 6
732 6
34 9
119 10
34 9
732 6
628 12
455 7
628 12
73...

output:

> 999
> 10
> 7
> 9
> 9
> 8
> 11
> 7
> 10
> 6
> 10
> 6
> 9
> 5
> 8
> 7
> 4
> 6
> 7
> 5
> 3
> 8
> 6
> 7
> 8
> 9
> 7
> 6
> 11
> 5
> 6
> 6
> 6
> 11
> 5
> 6
> 4
> 7
> 3
> 6
> 8
> 10
> 7
> 5
> 12
> 7
> 11
> 4
> 2
> 5
> 7
> 11
> 9
> 10
> 8
> 9
> 4
> 11
> 3
> 8
> 7
> 9
> 13
> 8
> 6
> 7
> 9
> 10
> 7
> 9
> 8
...

result:

ok correct! (10 test cases)

Test #6:

score: 0
Accepted
time: 220ms
memory: 5412kb

input:

4
1 999
1000 25
684 16
987 21
684 16
14 23
767 14
333 26
767 14
374 21
767 14
14 23
684 16
261 22
917 21
952 20
917 21
261 22
684 16
902 23
656 21
902 23
684 16
269 16
62 16
450 29
930 19
450 29
62 16
269 16
684 16
1000 25
798 24
287 28
307 23
287 28
134 20
737 14
134 20
842 19
134 20
547 18
134 20
...

output:

> 999
> 25
> 16
> 21
> 15
> 23
> 14
> 26
> 13
> 21
> 12
> 22
> 14
> 22
> 21
> 20
> 20
> 21
> 13
> 23
> 21
> 22
> 12
> 16
> 16
> 29
> 19
> 28
> 15
> 15
> 11
> 24
> 24
> 28
> 23
> 27
> 20
> 14
> 19
> 19
> 18
> 18
> 17
> 26
> 15
> 13
> 14
> 25
> 19
> 23
> 18
> 22
> 17
> 24
> 23
> 14
> 22
> 19
> 21
> 18...

result:

ok correct! (4 test cases)

Test #7:

score: 0
Accepted
time: 192ms
memory: 5232kb

input:

4
1 199
200 102
92 110
200 102
12 94
184 90
12 94
23 104
12 94
200 102
189 101
80 96
189 101
50 94
189 101
188 101
110 97
188 101
189 101
96 99
98 95
96 99
189 101
200 102
88 102
172 100
88 102
66 108
117 106
66 108
150 105
36 104
150 105
144 109
150 105
46 102
150 105
66 108
88 102
143 91
40 91
127...

output:

> 199
> 102
> 110
> 101
> 94
> 90
> 93
> 104
> 92
> 100
> 101
> 96
> 100
> 94
> 99
> 101
> 97
> 100
> 98
> 99
> 95
> 98
> 97
> 99
> 102
> 100
> 101
> 108
> 106
> 107
> 105
> 104
> 104
> 109
> 103
> 102
> 102
> 106
> 100
> 91
> 91
> 103
> 90
> 108
> 89
> 90
> 86
> 97
> 99
> 96
> 85
> 89
> 99
> 101
> ...

result:

ok correct! (4 test cases)

Test #8:

score: 0
Accepted
time: 95ms
memory: 5512kb

input:

4
1 140
141 140
140 140
141 140
139 140
141 140
138 140
141 140
137 140
141 140
136 140
141 140
135 140
141 140
134 140
141 140
133 140
141 140
132 140
141 140
131 140
141 140
130 140
141 140
129 140
141 140
128 140
141 140
127 140
141 140
126 140
141 140
125 140
141 140
124 140
141 140
123 140
141 ...

output:

> 140
> 140
> 140
> 139
> 140
> 138
> 140
> 137
> 140
> 136
> 140
> 135
> 140
> 134
> 140
> 133
> 140
> 132
> 140
> 131
> 140
> 130
> 140
> 129
> 140
> 128
> 140
> 127
> 140
> 126
> 140
> 125
> 140
> 124
> 140
> 123
> 140
> 122
> 140
> 121
> 140
> 120
> 140
> 119
> 140
> 118
> 140
> 117
> 140
> 116
...

result:

ok correct! (4 test cases)

Test #9:

score: 0
Accepted
time: 98ms
memory: 4860kb

input:

4
1 2498
2499 2
2500 2498
2499 2
1 2498
2498 2
2500 2498
2498 2
1 2498
2497 2
2500 2498
2497 2
1 2498
2496 2
2500 2498
2496 2
1 2498
2495 2
2500 2498
2495 2
1 2498
2494 2
2500 2498
2494 2
1 2498
2493 2
2500 2498
2493 2
1 2498
2492 2
2500 2498
2492 2
1 2498
2491 2
2500 2498
2491 2
1 2498
2490 2
2500 ...

output:

> 2498
> 2
> 2498
> 1
> 2497
> 2
> 2497
> 1
> 2496
> 2
> 2496
> 1
> 2495
> 2
> 2495
> 1
> 2494
> 2
> 2494
> 1
> 2493
> 2
> 2493
> 1
> 2492
> 2
> 2492
> 1
> 2491
> 2
> 2491
> 1
> 2490
> 2
> 2490
> 1
> 2489
> 2
> 2489
> 1
> 2488
> 2
> 2488
> 1
> 2487
> 2
> 2487
> 1
> 2486
> 2
> 2486
> 1
> 2485
> 2
> 2...

result:

ok correct! (4 test cases)

Extra Test:

score: 0
Extra Test Passed