QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#538016#4565. Rarest InsectsYahia_Emara#0 18ms12032kbC++203.0kb2024-08-30 20:54:222024-08-30 20:54:23

Judging History

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

  • [2024-08-30 20:54:23]
  • 评测
  • 测评结果:0
  • 用时:18ms
  • 内存:12032kb
  • [2024-08-30 20:54:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define dbg(x) cout << (#x) << " : " << x << endl
#define pb push_back
#define bk(x) x.back()
#define all(x) x.begin(),x.end()
#define LOOP(n) for(int rp=0;rp<n;rp++)
#define sq(x) ((x)*(x))
typedef long long ll;
typedef long double dl;
const int SZ=5e5+7;
const ll INF=1e18+7;
const dl eps=1e-9;
int MOD=1e9+7;
mt19937_64 rng(time(0));
int rnd(int l,int r){
    return uniform_int_distribution<int>(l,r)(rng);
}
ll trig(ll x){
    return x*(x+1)/2;
}
int getN(){
    int n;cin >> n;
    return n;
}
#define cmbntrcs fact[0]=1;for(int i=1;i<SZ;i++)fact[i]=mul(fact[i-1],i);finv[SZ-1]=inv(fact[SZ-1]);for(int i=SZ-2;i>0;i--)finv[i]=mul(finv[i+1],i+1);
int fact[SZ],finv[SZ];
int add(int x,int y,int MOD=MOD){
    x+=y;if(x>=MOD)x-=MOD;
    return x;
}
int sub(int x,int y,int MOD=MOD){
    x-=y;if(x<0)x+=MOD;
    return x;
}
int mul(int x,int y,int MOD=MOD){
    return(x*1ll*y)%MOD;
}
int pwr(int x,ll b,int MOD=MOD){
    int rt=1;
    while(b>0){
        if(b&1)rt=mul(rt,x,MOD);
        x=mul(x,x,MOD),b>>=1;
    }
    return rt;
}
int inv(int x,int MOD=MOD){
    return pwr(x,MOD-2,MOD);
}
#include "insects.h"
//#include "stub.cpp"
int n,p[SZ],a[SZ],k,vs[SZ];
vector<int>v;
void ins(int i){
    i=p[i];
    vs[i]=1;
    move_inside(i);
    v.pb(i);
}
void dlt(){
    vs[bk(v)]=0;
    move_outside(bk(v));
    v.pop_back();
}
void permdlt(){
    vs[bk(v)]=2;
    move_outside(bk(v));
    v.pop_back();
}
int card(){
    return press_button();
}
bool f(int C){
    while(card()>C)dlt();
    for(int i=0;i<n;i++){
        if(vs[p[i]])continue;
        ins(i);
        if(card()>C)dlt();
    }
    if(C*k==sz(v))return 1;
    return 0;
}
int min_cardinality(int N){
    n=N;
    for(int i=0;i<n;i++)p[i]=i,swap(p[i],p[rnd(0,i)]);
    for(int i=0;i<n;i++){
        ins(i);
        if(card()>1)dlt();
    }
    k=sz(v);
    if(k==1)return n;
    if(k<=8){
        vector<int>w=v;
        while(sz(v))dlt();
        for(int i=0;i<k;i++)swap(w[i],w[rnd(0,i)]);
        int C=0,ans=1e9;
        for(int i=0;i<k-1;i++){
            ins(w[i]);
            for(int i=0;i<n;i++){
                if(vs[p[i]])continue;
                ins(i);
                if(card()!=sz(v))dlt();
            }
            C+=sz(v),ans=min(ans,sz(v));
            while(sz(v))permdlt();
        }
        ans=min(ans,n-C);
        return ans;
    }
    for(int i=0;i<k;i++)swap(v[i],v[rnd(0,i)]);
    while(sz(v)>1)dlt();
    for(int i=0;i<n;i++){
        if(vs[p[i]])continue;
        ins(i);
        if(card()!=sz(v))dlt();
    }
    int l=2,r=min(n/k,sz(v)),ans=1;
    while(l<=r){
        int md=(l+r)>>1;
        if(f(md))l=md+1,ans=md;
        else r=md-1;
    }
    return ans;
}
/*int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    //cout << fixed << setprecision(12);
    int tt=1;
    //cin >> tt;
    LOOP(tt){
        //code
    }
    return 0;
}*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 0ms
memory: 9940kb

input:

6
1
1
1
2
2
2
1
1
2
3
3
1
1

output:

8
0 0
8
2
8
0 2
8
2
8
0 1
8
2
8
0 5
8
2
8
1 5
8
0 4
8
2
8
1 4
8
0 3
8
2
8
1 3
8
1 1
8
1 2
8
1 0
8
0 2
8
0 0
8
2
8
1 0
8
0 1
8
2
8
1 1
8
0 5
8
2
8
0 4
8
2
8
0 3
8
2
8
1 3
8
1 4
8
1 5
8
1 2
8
0 1
8
0 0
8
2
8
1 0
8
0 3
8
2
8
1 3
8
1 1
8
3 1

result:

ok 

Test #2:

score: 10
Accepted
time: 1ms
memory: 10068kb

input:

2
1
2

output:

8
0 0
8
2
8
0 1
8
2
8
1 1
8
3 2

result:

ok 

Test #3:

score: 10
Accepted
time: 2ms
memory: 9984kb

input:

2
1
1
1

output:

8
0 0
8
2
8
0 1
8
2
8
1 1
8
1 0
8
0 0
8
0 1
8
2
8
1 1
8
1 0
8
3 1

result:

ok 

Test #4:

score: 10
Accepted
time: 1ms
memory: 10272kb

input:

3
1
1
2
1
1

output:

8
0 0
8
2
8
0 2
8
2
8
0 1
8
2
8
1 1
8
1 2
8
1 0
8
0 0
8
0 2
8
2
8
1 2
8
0 1
8
2
8
1 1
8
1 0
8
3 1

result:

ok 

Test #5:

score: 10
Accepted
time: 1ms
memory: 9992kb

input:

5
1
1
2
2
2
1
1
2
3

output:

8
0 0
8
2
8
0 2
8
2
8
0 1
8
2
8
1 1
8
0 3
8
2
8
1 3
8
0 4
8
2
8
1 4
8
1 2
8
1 0
8
0 0
8
0 2
8
2
8
1 2
8
0 1
8
2
8
1 1
8
0 3
8
2
8
0 4
8
2
8
1 4
8
1 3
8
1 0
8
3 2

result:

ok 

Test #6:

score: 10
Accepted
time: 2ms
memory: 9984kb

input:

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

output:

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

result:

ok 

Test #7:

score: 10
Accepted
time: 2ms
memory: 10080kb

input:

199
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 138
8
2
8
0 68
8
2
8
1 68
8
0 97
8
2
8
1 97
8
0 120
8
2
8
1 120
8
0 10
8
2
8
1 10
8
0 20
8
2
8
1 20
8
0 116
8
2
8
1 116
8
0 3
8
2
8
1 3
8
0 18
8
2
8
1 18
8
0 81
8
2
8
1 81
8
0 112
8
2
8
1 112
8
0 163
8
2
8
1 163
8
0 62
8
2
8
1 62
8
0 137
8
2
8
1 137
8
0 21
8
2
8
1 21
8
0 139
8
2
8
1 139
8
0 174
...

result:

ok 

Test #8:

score: 10
Accepted
time: 3ms
memory: 10008kb

input:

200
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

8
0 138
8
2
8
0 68
8
2
8
0 97
8
2
8
0 120
8
2
8
0 10
8
2
8
0 20
8
2
8
0 116
8
2
8
0 3
8
2
8
0 18
8
2
8
0 81
8
2
8
0 112
8
2
8
0 163
8
2
8
0 62
8
2
8
0 137
8
2
8
0 21
8
2
8
0 139
8
2
8
0 174
8
2
8
0 8
8
2
8
0 42
8
2
8
0 61
8
2
8
0 144
8
2
8
0 24
8
2
8
0 99
8
2
8
0 12
8
2
8
0 101
8
2
8
0 152
8
2
8
0 1...

result:

ok 

Test #9:

score: 10
Accepted
time: 5ms
memory: 10008kb

input:

200
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 138
8
2
8
0 68
8
2
8
0 97
8
2
8
0 120
8
2
8
0 10
8
2
8
0 20
8
2
8
0 116
8
2
8
0 3
8
2
8
0 18
8
2
8
0 81
8
2
8
0 112
8
2
8
1 112
8
0 163
8
2
8
1 163
8
0 62
8
2
8
1 62
8
0 137
8
2
8
1 137
8
0 21
8
2
8
1 21
8
0 139
8
2
8
0 174
8
2
8
0 8
8
2
8
0 42
8
2
8
0 61
8
2
8
1 61
8
0 144
8
2
8
1 144
8
0 24
8
...

result:

ok 

Test #10:

score: 10
Accepted
time: 5ms
memory: 10016kb

input:

198
1
2
2
1
1
1
2
2
1
1
1
1
2
2
2
1
2
2
2
1
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 138
8
2
8
0 68
8
2
8
1 68
8
0 97
8
2
8
1 97
8
0 120
8
2
8
0 10
8
2
8
0 20
8
2
8
0 116
8
2
8
1 116
8
0 3
8
2
8
1 3
8
0 18
8
2
8
0 81
8
2
8
0 112
8
2
8
0 163
8
2
8
0 62
8
2
8
1 62
8
0 137
8
2
8
1 137
8
0 21
8
2
8
1 21
8
0 139
8
2
8
0 174
8
2
8
1 174
8
0 8
8
2
8
1 8
8
0 42
8
2
8
1 42
8
0 61
8
2
8
0...

result:

ok 

Test #11:

score: 10
Accepted
time: 3ms
memory: 8220kb

input:

199
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 138
8
2
8
0 68
8
2
8
1 68
8
0 97
8
2
8
1 97
8
0 120
8
2
8
1 120
8
0 10
8
2
8
1 10
8
0 20
8
2
8
1 20
8
0 116
8
2
8
1 116
8
0 3
8
2
8
1 3
8
0 18
8
2
8
1 18
8
0 81
8
2
8
1 81
8
0 112
8
2
8
1 112
8
0 163
8
2
8
1 163
8
0 62
8
2
8
1 62
8
0 137
8
2
8
1 137
8
0 21
8
2
8
1 21
8
0 139
8
2
8
1 139
8
0 174
...

result:

ok 

Test #12:

score: 10
Accepted
time: 3ms
memory: 10008kb

input:

197
1
2
2
2
1
2
1
2
1
2
2
2
2
2
1
2
1
1
2
2
2
1
2
2
1
2
2
2
1
2
2
2
1
2
1
2
1
2
1
1
1
1
1
1
2
2
1
2
2
1
2
1
2
2
1
1
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
1
1
1
2
1
1
1
1
2
1
2
1
1
2
1
1
1
2
1
1
1
1
1
1
2
2
1
2
2
2
2
1
2
2
1
2
1
1
1
1
1
2
1
1
2
1
1
2
1
1
2
2
1
2
1
1
1
1
1
1
1
2
2
1
2
2
2
1
1
1
...

output:

8
0 138
8
2
8
0 68
8
2
8
1 68
8
0 97
8
2
8
1 97
8
0 120
8
2
8
1 120
8
0 10
8
2
8
0 20
8
2
8
1 20
8
0 116
8
2
8
0 3
8
2
8
1 3
8
0 18
8
2
8
0 81
8
2
8
1 81
8
0 112
8
2
8
1 112
8
0 163
8
2
8
1 163
8
0 62
8
2
8
1 62
8
0 137
8
2
8
1 137
8
0 21
8
2
8
0 139
8
2
8
1 139
8
0 174
8
2
8
0 8
8
2
8
0 42
8
2
8
1 ...

result:

ok 

Test #13:

score: 0
Wrong Answer
time: 0ms
memory: 10012kb

input:

197
1
1
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 138
8
2
8
0 68
8
2
8
0 97
8
2
8
0 120
8
2
8
1 120
8
0 10
8
2
8
0 20
8
2
8
1 20
8
0 116
8
2
8
1 116
8
0 3
8
2
8
1 3
8
0 18
8
2
8
1 18
8
0 81
8
2
8
1 81
8
0 112
8
2
8
1 112
8
0 163
8
2
8
1 163
8
0 62
8
2
8
1 62
8
0 137
8
2
8
1 137
8
0 21
8
2
8
1 21
8
0 139
8
2
8
1 139
8
0 174
8
2
8
1 174
8
0 8
8
2...

result:

wrong answer Wrong answer.

Subtask #2:

score: 0
Wrong Answer

Test #24:

score: 15
Accepted
time: 2ms
memory: 10012kb

input:

1000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 138
8
2
8
0 295
8
2
8
1 295
8
0 676
8
2
8
1 676
8
0 802
8
2
8
1 802
8
0 883
8
2
8
1 883
8
0 20
8
2
8
1 20
8
0 116
8
2
8
1 116
8
0 925
8
2
8
1 925
8
0 677
8
2
8
1 677
8
0 81
8
2
8
1 81
8
0 203
8
2
8
1 203
8
0 352
8
2
8
1 352
8
0 649
8
2
8
1 649
8
0 137
8
2
8
1 137
8
0 898
8
2
8
1 898
8
0 648
8
2
...

result:

ok 

Test #25:

score: 15
Accepted
time: 0ms
memory: 9996kb

input:

1000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 138
8
2
8
0 295
8
2
8
0 676
8
2
8
0 802
8
2
8
0 883
8
2
8
0 20
8
2
8
0 116
8
2
8
0 925
8
2
8
0 677
8
2
8
0 81
8
2
8
0 203
8
2
8
0 352
8
2
8
0 649
8
2
8
0 137
8
2
8
0 898
8
2
8
0 648
8
2
8
0 331
8
2
8
0 467
8
2
8
0 42
8
2
8
0 798
8
2
8
0 457
8
2
8
0 24
8
2
8
0 944
8
2
8
0 12
8
2
8
0 562
8
2
8
0 8...

result:

ok 

Test #26:

score: 15
Accepted
time: 2ms
memory: 7956kb

input:

999
1
1
1
1
2
1
1
1
1
2
1
2
1
2
1
1
1
1
1
1
2
1
2
1
1
2
2
2
1
2
2
2
2
1
2
1
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 138
8
2
8
0 295
8
2
8
0 676
8
2
8
0 802
8
2
8
0 883
8
2
8
1 883
8
0 20
8
2
8
0 116
8
2
8
0 925
8
2
8
0 677
8
2
8
0 81
8
2
8
1 81
8
0 203
8
2
8
0 352
8
2
8
1 352
8
0 649
8
2
8
0 137
8
2
8
1 137
8
0 898
8
2
8
0 648
8
2
8
0 331
8
2
8
0 467
8
2
8
0 42
8
2
8
0 798
8
2
8
0 457
8
2
8
1 457
8
0 24
8
2
8...

result:

ok 

Test #27:

score: 15
Accepted
time: 4ms
memory: 7912kb

input:

999
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
2
1
2
2
1
1
2
2
2
2
1
2
1
2
1
2
2
2
2
2
2
2
1
2
2
1
2
1
2
2
1
1
1
2
2
2
1
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 138
8
2
8
0 295
8
2
8
0 676
8
2
8
0 802
8
2
8
0 883
8
2
8
0 20
8
2
8
0 116
8
2
8
0 925
8
2
8
0 677
8
2
8
0 81
8
2
8
0 203
8
2
8
1 203
8
0 352
8
2
8
1 352
8
0 649
8
2
8
1 649
8
0 137
8
2
8
1 137
8
0 898
8
2
8
0 648
8
2
8
0 331
8
2
8
1 331
8
0 467
8
2
8
0 42
8
2
8
1 42
8
0 798
8
2
8
1 798
8
0 457
...

result:

ok 

Test #28:

score: 15
Accepted
time: 12ms
memory: 8240kb

input:

996
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 607
8
2
8
0 464
8
2
8
1 464
8
0 146
8
2
8
1 146
8
0 420
8
2
8
1 420
8
0 437
8
2
8
1 437
8
0 349
8
2
8
1 349
8
0 941
8
2
8
1 941
8
0 322
8
2
8
1 322
8
0 587
8
2
8
1 587
8
0 191
8
2
8
1 191
8
0 16
8
2
8
1 16
8
0 27
8
2
8
1 27
8
0 38
8
2
8
1 38
8
0 73
8
2
8
1 73
8
0 294
8
2
8
1 294
8
0 692
8
2
8
1 ...

result:

ok 

Test #29:

score: 15
Accepted
time: 0ms
memory: 10020kb

input:

995
1
1
2
2
1
1
1
1
2
1
2
1
2
2
2
2
1
2
2
1
2
2
2
2
1
1
1
2
2
1
1
2
2
2
2
1
2
2
2
2
2
2
2
1
2
2
1
1
2
2
1
2
1
2
1
1
2
2
1
2
1
1
2
2
2
1
1
1
2
2
2
1
1
2
1
1
1
1
2
1
1
1
1
2
2
2
1
1
2
2
2
1
2
2
1
2
2
1
1
2
2
1
1
2
1
2
1
1
2
2
1
1
2
1
1
2
2
1
1
1
2
1
2
2
2
1
2
2
2
1
2
1
1
2
2
1
2
1
2
2
2
1
1
1
2
2
2
1
...

output:

8
0 607
8
2
8
0 464
8
2
8
0 146
8
2
8
1 146
8
0 420
8
2
8
1 420
8
0 437
8
2
8
0 349
8
2
8
0 941
8
2
8
0 322
8
2
8
0 587
8
2
8
1 587
8
0 191
8
2
8
0 16
8
2
8
1 16
8
0 27
8
2
8
0 38
8
2
8
1 38
8
0 73
8
2
8
1 73
8
0 294
8
2
8
1 294
8
0 692
8
2
8
1 692
8
0 917
8
2
8
0 163
8
2
8
1 163
8
0 766
8
2
8
1 766...

result:

ok 

Test #30:

score: 0
Wrong Answer
time: 9ms
memory: 12032kb

input:

998
1
1
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 607
8
2
8
0 464
8
2
8
0 146
8
2
8
1 146
8
0 420
8
2
8
0 437
8
2
8
1 437
8
0 349
8
2
8
0 941
8
2
8
1 941
8
0 322
8
2
8
1 322
8
0 587
8
2
8
1 587
8
0 191
8
2
8
1 191
8
0 16
8
2
8
1 16
8
0 27
8
2
8
1 27
8
0 38
8
2
8
1 38
8
0 73
8
2
8
1 73
8
0 294
8
2
8
1 294
8
0 692
8
2
8
1 692
8
0 917
8
2
8
1 917
...

result:

wrong answer Wrong answer.

Subtask #3:

score: 0
Wrong Answer

Test #43:

score: 75
Accepted
time: 2ms
memory: 10240kb

input:

2
1
2

output:

8
0 0
8
2
8
0 1
8
2
8
1 1
8
3 2

result:

ok 

Test #44:

score: 75
Accepted
time: 0ms
memory: 10276kb

input:

2
1
1
1

output:

8
0 0
8
2
8
0 1
8
2
8
1 1
8
1 0
8
0 0
8
0 1
8
2
8
1 1
8
1 0
8
3 1

result:

ok 

Test #45:

score: 75
Accepted
time: 0ms
memory: 9944kb

input:

3
1
1
2
1
2

output:

8
0 0
8
2
8
0 2
8
2
8
0 1
8
2
8
1 1
8
1 2
8
1 0
8
0 1
8
0 0
8
2
8
1 0
8
0 2
8
2
8
1 2
8
1 1
8
3 1

result:

ok 

Test #46:

score: 75
Accepted
time: 1ms
memory: 10076kb

input:

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

output:

8
0 4
8
2
8
0 5
8
2
8
1 5
8
0 1
8
2
8
1 1
8
0 3
8
2
8
1 3
8
0 0
8
2
8
1 0
8
0 2
8
2
8
1 2
8
1 4
8
0 1
8
0 4
8
2
8
0 5
8
2
8
0 3
8
2
8
0 0
8
2
8
0 2
8
2
8
1 2
8
1 0
8
1 3
8
1 5
8
1 4
8
1 1
8
3 1

result:

ok 

Test #47:

score: 75
Accepted
time: 0ms
memory: 8224kb

input:

10
1
2
1
2
2
2
2
2
2
2
2
3
3
4
5
5
5
5
6

output:

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

result:

ok 

Test #48:

score: 75
Accepted
time: 0ms
memory: 10280kb

input:

2000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 607
8
2
8
0 1705
8
2
8
1 1705
8
0 146
8
2
8
1 146
8
0 420
8
2
8
1 420
8
0 437
8
2
8
1 437
8
0 349
8
2
8
1 349
8
0 941
8
2
8
1 941
8
0 322
8
2
8
1 322
8
0 587
8
2
8
1 587
8
0 1939
8
2
8
1 1939
8
0 16
8
2
8
1 16
8
0 27
8
2
8
1 27
8
0 1159
8
2
8
1 1159
8
0 1100
8
2
8
1 1100
8
0 1922
8
2
8
1 1922
8
...

result:

ok 

Test #49:

score: 75
Accepted
time: 8ms
memory: 7964kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 607
8
2
8
0 1705
8
2
8
0 146
8
2
8
0 420
8
2
8
0 437
8
2
8
0 349
8
2
8
0 941
8
2
8
0 322
8
2
8
0 587
8
2
8
0 1939
8
2
8
0 16
8
2
8
0 27
8
2
8
0 1159
8
2
8
0 1100
8
2
8
0 1922
8
2
8
0 692
8
2
8
0 1585
8
2
8
0 1132
8
2
8
0 766
8
2
8
0 1581
8
2
8
0 778
8
2
8
0 909
8
2
8
0 933
8
2
8
0 1474
8
2
8
0 6...

result:

ok 

Test #50:

score: 70.57
Acceptable Answer
time: 18ms
memory: 7900kb

input:

2000
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
2
1
1
1
1
2
2
1
2
2
1
1
1
1
2
2
1
1
1
1
2
1
2
2
1
2
1
1
1
2
2
2
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 607
8
2
8
0 1705
8
2
8
0 146
8
2
8
0 420
8
2
8
0 437
8
2
8
0 349
8
2
8
0 941
8
2
8
0 322
8
2
8
0 587
8
2
8
0 1939
8
2
8
0 16
8
2
8
1 16
8
0 27
8
2
8
0 1159
8
2
8
1 1159
8
0 1100
8
2
8
0 1922
8
2
8
0 692
8
2
8
0 1585
8
2
8
0 1132
8
2
8
1 1132
8
0 766
8
2
8
0 1581
8
2
8
0 778
8
2
8
0 909
8
2
8
1 9...

result:

points 0.94093333330 points  0.94093333330

Test #51:

score: 61.59
Acceptable Answer
time: 8ms
memory: 10024kb

input:

2000
1
1
1
1
1
1
1
1
1
2
1
1
2
1
2
2
2
2
1
1
2
2
1
2
2
2
1
1
1
1
1
1
2
1
2
2
1
2
1
1
2
2
1
2
1
1
2
2
1
2
1
1
1
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 607
8
2
8
0 1705
8
2
8
0 146
8
2
8
0 420
8
2
8
0 437
8
2
8
0 349
8
2
8
0 941
8
2
8
0 322
8
2
8
0 587
8
2
8
0 1939
8
2
8
1 1939
8
0 16
8
2
8
0 27
8
2
8
0 1159
8
2
8
1 1159
8
0 1100
8
2
8
0 1922
8
2
8
1 1922
8
0 692
8
2
8
1 692
8
0 1585
8
2
8
1 1585
8
0 1132
8
2
8
1 1132
8
0 766
8
2
8
0 1581
8
2
8...

result:

points 0.82120 points  0.82120

Test #52:

score: 75
Accepted
time: 5ms
memory: 10012kb

input:

2000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1913
8
2
8
0 1251
8
2
8
1 1251
8
0 1011
8
2
8
1 1011
8
0 630
8
2
8
1 630
8
0 715
8
2
8
1 715
8
0 382
8
2
8
1 382
8
0 1301
8
2
8
1 1301
8
0 878
8
2
8
1 878
8
0 1478
8
2
8
1 1478
8
0 558
8
2
8
1 558
8
0 1965
8
2
8
1 1965
8
0 307
8
2
8
1 307
8
0 1349
8
2
8
1 1349
8
0 1951
8
2
8
1 1951
8
0 1429
8
2
...

result:

ok 

Test #53:

score: 75
Accepted
time: 5ms
memory: 10288kb

input:

2000
1
1
2
2
2
1
1
2
2
1
2
1
1
1
2
2
1
1
2
1
2
1
2
2
2
2
1
1
1
1
1
2
2
1
2
2
2
2
2
1
1
1
2
1
2
1
2
1
2
2
1
2
2
1
2
2
2
1
2
1
2
1
1
2
1
1
1
1
1
2
2
1
2
2
1
2
1
2
1
2
2
2
1
1
2
1
1
2
2
1
1
1
2
1
2
1
1
1
1
1
2
1
2
1
1
2
2
1
1
2
1
1
2
1
2
2
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
2
1
1
1
2
1
1
2
2
1
1
2
2
2...

output:

8
0 1913
8
2
8
0 1251
8
2
8
0 1011
8
2
8
1 1011
8
0 630
8
2
8
1 630
8
0 715
8
2
8
1 715
8
0 382
8
2
8
0 1301
8
2
8
0 878
8
2
8
1 878
8
0 1478
8
2
8
1 1478
8
0 558
8
2
8
0 1965
8
2
8
1 1965
8
0 307
8
2
8
0 1349
8
2
8
0 1951
8
2
8
0 1429
8
2
8
1 1429
8
0 1672
8
2
8
1 1672
8
0 349
8
2
8
0 117
8
2
8
0 7...

result:

ok 

Test #54:

score: 0
Wrong Answer
time: 11ms
memory: 10004kb

input:

2000
1
1
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1913
8
2
8
0 1251
8
2
8
0 1011
8
2
8
1 1011
8
0 630
8
2
8
0 715
8
2
8
1 715
8
0 382
8
2
8
1 382
8
0 1301
8
2
8
0 878
8
2
8
1 878
8
0 1478
8
2
8
1 1478
8
0 558
8
2
8
1 558
8
0 1965
8
2
8
1 1965
8
0 307
8
2
8
1 307
8
0 1349
8
2
8
1 1349
8
0 1951
8
2
8
1 1951
8
0 1429
8
2
8
1 1429
8
0 1672
8
2
8
1 ...

result:

wrong answer Wrong answer.