QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#75677#5463. Range Closest Pair of Points QuerysnukeAC ✓4636ms498508kbC++206.3kb2023-02-06 07:06:542023-02-06 07:06:56

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-06 07:06:56]
  • 评测
  • 测评结果:AC
  • 用时:4636ms
  • 内存:498508kb
  • [2023-02-06 07:06:54]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < (t); ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define newline puts("")
using namespace std;
template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
template<typename T> using PQ = priority_queue<T,vc<T>,greater<T>>;
using uint = unsigned; using ull = unsigned long long;
using vi = vc<int>; using vvi = vv<int>; using vvvi = vv<vi>;
using ll = long long; using vl = vc<ll>; using vvl = vv<ll>; using vvvl = vv<vl>;
using P = pair<int,int>; using vp = vc<P>; using vvp = vv<P>;
int geti(){int x;scanf("%d",&x);return x;}
vi pm(int n, int s=0) { vi a(n); iota(rng(a),s); return a;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>istream& operator>>(istream&i,vc<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const T&v,const string& d=""){stringstream s;rep(i,sz(v))(i?s<<d:s)<<v[i];return s.str();}
template<typename T>ostream& operator<<(ostream&o,const vc<T>&v){if(sz(v))o<<join(v," ");return o;}
template<typename T1,typename T2>void operator--(pair<T1,T2>&a,int){a.fi--;a.se--;}
template<typename T1,typename T2>void operator++(pair<T1,T2>&a,int){a.fi--;a.se--;}
template<typename T>void operator--(vc<T>&a,int){for(T&x:a)x--;}
template<typename T>void operator++(vc<T>&a,int){for(T&x:a)x++;}
template<typename T>void operator+=(vc<T>&a,T b){for(T&x:a)x+=b;}
template<typename T>void operator+=(vc<T>&a,const vc<T>&b){a.insert(a.end(),rng(b));}
template<typename T1,typename T2>bool mins(T1& x,const T2&y){if(y<x){x=y;return true;}else return false;}
template<typename T1,typename T2>bool maxs(T1& x,const T2&y){if(x<y){x=y;return true;}else return false;}
template<typename Tx, typename Ty>Tx dup(Tx x, Ty y){return (x+y-1)/y;}
template<typename T>ll suma(const vc<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}
template<typename T>ll suma(const vv<T>&a){ll res(0);for(auto&&x:a)res+=suma(x);return res;}
template<typename T>void uni(T& a){sort(rng(a));a.erase(unique(rng(a)),a.end());}
template<typename T>void prepend(vc<T>&a,const T&x){a.insert(a.begin(),x);}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return;}
#define yes { puts("Yes"); return;}
#define no { puts("No"); return;}
// #define ret(x) { cout<<(x)<<endl; return;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define bn(x) ((1ll<<(x))-1)
const int di[] = {-1,0,1,0,-1,-1,1,1,0}, dj[] = {0,-1,0,1,-1,1,-1,1,0}; //^<v>

// - cannot use count
// - no move constructor (==> cannot use merge tech)
// - unordered_set by value: __gnu_pbds::null_type
// - no erase(iterator)
#include <ext/pb_ds/assoc_container.hpp>
using __gnu_pbds::gp_hash_table;
#define HT gp_hash_table
//https://codeforces.com/blog/entry/62393
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(uint64_t x) const {
    // static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    static const uint64_t FIXED_RANDOM = 0;
    return splitmix64(x + FIXED_RANDOM);
  }
  
  size_t operator()(pair<int,int> x)const{
    return operator()(uint64_t(x.first)<<32|x.second);
  }
};

// Binary Indexed Tree
struct bit {
  int n; vector<ll> d;
  bit() {}
  bit(int mx): n(mx+1), d(mx+1,LINF) {}
  void add(int i, ll x) {
    for (++i;i<n;i+=i&-i) mins(d[i],x);
  }
  ll get(int i) {
    ll x = LINF;
    for (++i;i;i-=i&-i) mins(x,d[i]);
    return x;
  }
};
//

ll pow2(ll x) { return x*x;}
ll dist(const P& a, const P& b) {
  return pow2(a.fi-b.fi)+pow2(a.se-b.se);
}

struct arr {
  array<int,6> a; int n;
  arr(): n(0) {}
  void push_back(int x) { a[n++] = x;}
  void erase(int x) {
    rep(i,n) if (a[i] == x) a[i] = a[--n];
  }
};

struct Solver {
  const int D = 27;
  struct Grid {
    int w, r;
    HT<ll,arr,custom_hash> g;
    const vp& ps; vl& md;
    Grid(int w, int n, const vp& ps, vl& md): w(w), r(n), ps(ps), md(md) {}
    ll tol(const P& p) { return (ll)(p.fi>>w)<<30|(p.se>>w);}
    ll tol(int i, int j) { return (ll)i<<30|j;}
    void add(int i, vi& js) {
      const P& p = ps[i];
      int gi = p.fi>>w, gj = p.se>>w;
      rep(v,9) {
        int ni = gi+di[v], nj = gj+dj[v];
        if (ni < 0 || nj < 0) continue;
        auto it = g.find(tol(ni,nj));
        if (it == g.end()) continue;
        const arr& a = it->se;
        rep(ai,a.n) {
          int j = a.a[ai];
          if (mins(md[j], dist(p,ps[j]))) js.pb(j);
        }
      }
      g[tol(gi,gj)].pb(i);
    }
    void del(int l) {
      while (l < r) {
        --r;
        g.find(tol(ps[r]))->se.erase(r);
      }
    }
  };

  void solve() {
    int n, q;
    cin>>n>>q;
    vp ps(n);
    cin>>ps;

    vvp qs(n);
    rep(qi,q) {
      int l, r;
      cin>>l>>r;
      qs[l-1].eb(r,qi);
    }

    bit d(n);
    vl md(n,LINF);
    vc<Grid> gs;
    rep(i,D) gs.eb(i,n,ps,md);

    vi rd(n,D-1);
    vl ans(q);
    drep(i,n) {
      vi js;
      rep(di,D) gs[di].add(i,js);
      uni(js);
      for (int j : js) {
        while (rd[j] >= 0) {
          if (md[j]*4 > (1ll<<(rd[j]<<1))) break;
          gs[rd[j]--].del(j);
        }
        d.add(j,md[j]);
      }
      for (auto [r,qi] : qs[i]) ans[qi] = d.get(r-1);
    }
    rep(i,q) printf("%lld\n",ans[i]);
  }
};

int main() {
  // cin.tie(nullptr); ios::sync_with_stdio(false);
  int ts = 1;
  // scanf("%d",&ts);
  rep1(ti,ts) {
    Solver solver;
    solver.solve();
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

input:

5 5
2 4
1 1
3 3
5 1
4 2
1 5
2 3
2 4
3 5
1 3

output:

2
8
8
2
2

result:

ok 5 number(s): "2 8 8 2 2"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3624kb

input:

2 1
1 1
1 1
1 2

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

2 1
1 100000000
100000000 1
1 2

output:

19999999600000002

result:

ok 1 number(s): "19999999600000002"

Test #4:

score: 0
Accepted
time: 171ms
memory: 9612kb

input:

20000 250000
3 10
5 4
4 7
1 5
2 1
10 6
2 3
8 4
2 1
8 5
9 8
7 7
4 5
2 7
9 4
9 10
3 2
9 5
10 2
9 2
3 1
9 9
6 5
9 5
9 10
9 1
1 2
8 8
3 4
7 6
6 2
6 8
6 6
8 4
10 2
1 1
10 2
8 3
4 4
5 5
5 1
4 9
7 6
6 8
6 4
1 6
10 3
3 2
4 10
6 8
9 7
2 10
7 8
10 7
3 2
5 1
6 4
7 9
1 3
4 9
4 8
9 4
5 2
2 2
9 2
9 2
9 6
6 9
8 7
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #5:

score: 0
Accepted
time: 177ms
memory: 12628kb

input:

20000 250000
72 45
72 34
34 10
20 96
79 39
43 5
72 49
56 85
1 72
44 70
73 89
69 76
49 89
57 38
39 9
33 47
22 3
96 41
90 82
25 6
72 92
73 38
53 21
16 88
59 9
54 2
14 6
7 94
99 68
27 82
70 50
81 81
60 81
2 98
33 19
98 9
35 36
49 66
86 7
3 95
32 89
62 42
68 88
65 16
94 6
85 10
51 69
90 36
70 87
13 79
4...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 250000 numbers

Test #6:

score: 0
Accepted
time: 214ms
memory: 23052kb

input:

20000 250000
116 165
150 677
951 676
552 324
267 222
739 755
705 663
235 142
152 714
735 641
414 201
313 663
683 300
403 739
37 521
42 833
553 733
886 449
86 913
55 637
731 932
143 161
500 891
719 79
916 237
431 992
804 210
643 332
165 362
178 332
821 510
762 34
188 83
283 357
743 407
750 487
19 658...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
45
1
0
1
0
0
0
2
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
52
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
5
0
0
0
0
0
1
0
0
0
1
1
0
0
0
2
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #7:

score: 0
Accepted
time: 319ms
memory: 53580kb

input:

20000 250000
193144 901630
894860 3728
802840 155641
625273 792794
433205 942335
223506 874548
425235 550629
341169 950916
49296 305542
709463 512381
9742 994078
106664 845553
38691 373010
184728 331946
344567 438182
854583 291040
94405 555036
56330 494420
928479 123077
796593 798314
300374 490072
2...

output:

3576676
1219565
93925
2336788
8872
68
137
842657
137
8560936
13914025
28521
88362
8872
8872
52996
12869
86297
68
8137625
93925
12869
86297
8872
8872
8872
47888
8872
12869
107860
12869
59536
59536
425540
12869
59536
8872
93925
117225
137
137
52996
68
52996
137
8872
68
12869
137
68
86297
1514
159700
6...

result:

ok 250000 numbers

Test #8:

score: 0
Accepted
time: 406ms
memory: 72544kb

input:

20000 250000
65468917 46637638
46041830 58072288
95596278 49154795
57837493 40861050
21328886 69542502
7729300 7126264
2317013 48080367
75669670 20165373
93996778 88884044
8523082 62327896
123901 11925128
71901024 73104267
94991893 98591670
53591520 11543761
76785613 86286274
64694742 89591932
75687...

output:

185588005
3282196826
141969393
25769005
141969393
185588005
576346153849
141969393
141969393
185588005
141969393
141969393
141969393
141969393
135584833
141969393
141969393
485404589
1182793
1182793
35224007589
135584833
185588005
931246420
185588005
25769005
375240717
141969393
2245310308
239709665...

result:

ok 250000 numbers

Test #9:

score: 0
Accepted
time: 632ms
memory: 22716kb

input:

250000 250000
1 2
1 1
3 2
3 3
1 2
3 2
1 2
1 3
3 1
2 1
1 3
2 3
3 3
1 3
3 1
3 1
1 3
2 1
1 2
1 1
1 2
2 2
1 2
1 2
1 3
3 3
1 1
3 2
1 2
2 2
1 1
2 3
3 2
2 1
3 3
2 1
2 3
3 1
2 3
3 2
2 1
1 1
3 2
1 2
1 3
3 1
2 3
2 1
1 2
1 1
1 2
3 3
1 2
2 2
3 1
3 1
3 1
1 2
2 2
1 1
3 3
1 3
1 3
1 2
1 2
3 1
3 2
1 2
2 2
1 2
1 1
2 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #10:

score: 0
Accepted
time: 1104ms
memory: 68272kb

input:

250000 250000
65 333
64 141
52 164
104 499
329 292
187 279
178 394
92 488
223 487
457 262
355 475
466 223
450 293
397 22
390 379
257 389
339 162
228 267
446 78
116 3
28 400
63 319
255 491
459 301
340 321
183 340
469 6
288 268
383 446
456 13
478 383
109 79
142 317
132 219
168 347
30 398
59 453
192 33...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #11:

score: 0
Accepted
time: 1907ms
memory: 175156kb

input:

250000 250000
5939 214
4869 2285
3576 8124
1179 6365
863 9874
6034 7110
9688 5453
1631 1975
7330 8868
1035 8771
9222 9417
7858 1642
3145 4403
8553 6105
8162 2232
2192 4946
5925 8017
1235 5374
6897 5409
8507 8625
7239 4621
5581 4870
4979 1749
35 1282
9138 5489
1030 8851
4444 905
5808 4770
348 7535
16...

output:

1
4
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
25
1
0
0
0
1
0
0
0
0
0
0
2
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
4
0
0
0
1
21925
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 250000 numbers

Test #12:

score: 0
Accepted
time: 4585ms
memory: 498136kb

input:

250000 250000
7455187 75182576
14834779 53171998
80916167 45846874
44479602 88587946
22419247 21232863
45054521 14420458
26938419 38366452
40688894 64933635
58825078 27729802
43992064 49857990
80761962 17266078
67198634 69525730
78961694 90909521
86333066 79243240
75184949 63327693
20070526 51545836...

output:

345163988
17297
17297
17297
3342826
2692082
9929385
17297
17297
8796836
17297
1024786
17297
17297
11911909
17297
17297
1518912
39645
3342826
623969
17297
17297
9929385
17297
17297
1931549
346277845
17297
17297
11911909
117753730
17297
5756500
623969
1024786
17297
17297
4290746
17297
17297
623969
172...

result:

ok 250000 numbers

Test #13:

score: 0
Accepted
time: 4636ms
memory: 498156kb

input:

250000 250000
46988183 58848304
68248752 17909655
83617101 6540168
35239739 61188742
53626925 43849602
93050637 37107186
81895363 18264817
49186829 46896179
432608 14970834
27450067 64324424
95545626 36896275
99221358 60404199
53496911 74842046
75080552 5484539
24301428 65640142
96567779 65503273
98...

output:

364165
364165
364165
364165
1118420
364165
2875970
364165
364165
18782189
364165
2443444
2443444
364165
364165
2443444
477485
4069129
4832930
6161897
26896946
364165
26896946
2875970
1028485
16319272
1028485
364165
10848521
364165
893349
8344033
1861925
893349
16319272
2875970
2443444
364165
1028485...

result:

ok 250000 numbers

Test #14:

score: 0
Accepted
time: 4509ms
memory: 498508kb

input:

250000 250000
91248546 19112361
80003885 9173894
78946509 40597624
69292429 19443411
62836211 54539297
21113442 50348948
79804335 68234343
72628821 86879420
57634006 80551531
56031660 58204680
64883168 19157561
57708639 65267544
16502324 51487377
52951273 64713455
36315517 95949044
53263309 72456798...

output:

173585
1749061
17137028
173585
173585
173585
173585
173585
829306
245785
173585
3192869
173585
1100852
39267488
173585
173585
245785
14222466
245785
173585
173585
173585
173585
2558933
173585
173585
27213905
829306
353040509
1100852
173585
173585
20949364
1100852
173585
173585
173585
11259905
919450...

result:

ok 250000 numbers

Test #15:

score: 0
Accepted
time: 3103ms
memory: 48452kb

input:

240032 250000
50000000 50000000
50002262 76010790
50001271 86525300
98641920 50000129
50002536 73103650
33803461 50003187
50001627 17251861
84626110 50001450
14694851 50001386
50002865 30387041
50002785 29538241
3543741 50000335
50002609 72329120
10652441 50001005
69740280 50002853
50000834 8838131
...

output:

112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
...

result:

ok 250000 numbers

Test #16:

score: 0
Accepted
time: 2954ms
memory: 48332kb

input:

240032 250000
50000000 50000000
35893631 50003384
39734451 50003746
87851550 50001146
22238561 50002097
22864551 50002156
50000020 201591
24784961 50002337
50001288 13655071
50003130 66801310
33485161 50003157
4360711 50000412
16731971 50001578
11214771 50001058
50002790 70408710
50002188 23204071
5...

output:

112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
112470002
...

result:

ok 250000 numbers

Test #17:

score: 0
Accepted
time: 939ms
memory: 23224kb

input:

250000 250000
50000000 50000000
50000001 49999999
50000002 49999998
50000003 49999997
50000004 49999996
50000005 49999995
50000006 49999994
50000007 49999993
50000008 49999992
50000009 49999991
50000010 49999990
50000011 49999989
50000012 49999988
50000013 49999987
50000014 49999986
50000015 4999998...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #18:

score: 0
Accepted
time: 1020ms
memory: 69256kb

input:

250000 250000
50000000 50000000
50000001 49999999
50000002 49999998
50000003 49999997
50000004 49999996
50000005 49999995
50000006 49999994
50000007 49999993
50000008 49999992
50000009 49999991
50000010 49999990
50000011 49999989
50000012 49999988
50000013 49999987
50000014 49999986
50000015 4999998...

output:

1
2
2
1
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
1
2
2
1
2
1
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
1
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
1
2
1
1
2
1
2
2
2
1
2
2
2
2
2
1
2
1
1
2
1
2
2
2
2
1
1
1
2
2
1
2
2
2
1
2
1
1
...

result:

ok 250000 numbers