Submission #628381

# Submission time Handle Problem Language Result Execution time Memory
628381 2022-08-13T11:04:50 Z Sasha008 Rarest Insects (IOI22_insects) C++17
53.16 / 100
214 ms 364 KB
#include<bits/stdc++.h>
#include "insects.h"
//#pragma GCC optimize ("O3")
using namespace std;
#define el "\n"
#define se " "
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
const ll INF=1e18,ch=1e18;
ll a,b,c,d,n,COST,t,last,ab,ba,n1,n2,fl1,fl2,o1,o2,flag,flag1,flag2,g,m,m1,m2,i,j,lr,f,k,l,r,y,o,p,mx=-ch,mx1=-ch,mx2=-ch,q,q1,q2,q3,q4,mn=ch,mn1=ch,mn2=ch,f1,f2,f3,pos,ans,sum,sz=1,MOD=1e9+7,zero=0,a1,b1,c1,val,sum1,cur,res,ans1,res1,kk,kkk,cnt,cnt1,fl;
ll S[2005];
ll A[2005];
//void move_inside(int i)
//void move_outside(int i)
//int press_button()
bool pr(ll m)
{
    ans=0;
    for(i=0;i<n;i++)
    {
        if (S[i]==1) continue;
        move_inside(i);
        A[i]=1;
        if (press_button()+q>m)
        {
            A[i]=0;
            move_outside(i);
        }
        else
        {
            ans++;
        }
    }
    if ((m-q)*d==ans) return 1;
    return 0;
}
int min_cardinality(int N)
{
    n=N;
    d=0;
    for(i=0;i<n;i++)
    {
        move_inside(i);
        d++;S[i]=1;

        if (press_button()>1)
        {
            move_outside(i);
            d--;S[i]=0;
        }
    }
    for(i=0;i<n;i++)
    {
        if (S[i]==1) move_outside(i);
    }
    o=1;l=2;r=n/d;q=1;
    while(l<=r)
    {
        for(i=0;i<n;i++)
        {
            A[i]=0;
        }
        m=(l+r)/2;
        if (pr(m)==1)
        {
            o=m;
            l=m+1;
            q=m;
            for(i=0;i<n;i++)
            {
                if (A[i]==1)
                {
                    S[i]=1;
                    move_outside(i);
                }
            }
        }
        else
        {
            r=m-1;
            for(i=0;i<n;i++)
            {
                if (A[i]==1)
                {
                    move_outside(i);
                }
            }
        }
    }
    return o;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 3 ms 312 KB Output is correct
7 Correct 2 ms 236 KB Output is correct
8 Correct 7 ms 256 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 14 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 12 ms 208 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 7 ms 208 KB Output is correct
15 Correct 5 ms 260 KB Output is correct
16 Correct 8 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 10 ms 208 KB Output is correct
19 Correct 10 ms 208 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 3 ms 312 KB Output is correct
7 Correct 2 ms 236 KB Output is correct
8 Correct 7 ms 256 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 14 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 12 ms 208 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 7 ms 208 KB Output is correct
15 Correct 5 ms 260 KB Output is correct
16 Correct 8 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 10 ms 208 KB Output is correct
19 Correct 10 ms 208 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
23 Correct 32 ms 308 KB Output is correct
24 Correct 11 ms 208 KB Output is correct
25 Correct 31 ms 320 KB Output is correct
26 Correct 17 ms 208 KB Output is correct
27 Correct 55 ms 208 KB Output is correct
28 Correct 15 ms 292 KB Output is correct
29 Correct 110 ms 312 KB Output is correct
30 Correct 55 ms 308 KB Output is correct
31 Correct 37 ms 208 KB Output is correct
32 Correct 19 ms 308 KB Output is correct
33 Correct 22 ms 312 KB Output is correct
34 Correct 41 ms 208 KB Output is correct
35 Correct 14 ms 340 KB Output is correct
36 Correct 43 ms 208 KB Output is correct
37 Correct 16 ms 304 KB Output is correct
38 Correct 27 ms 308 KB Output is correct
39 Correct 30 ms 208 KB Output is correct
40 Correct 19 ms 304 KB Output is correct
41 Correct 5 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 244 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 35 ms 312 KB Output is correct
8 Correct 13 ms 296 KB Output is correct
9 Correct 57 ms 312 KB Output is correct
10 Partially correct 34 ms 208 KB Output is partially correct
11 Partially correct 214 ms 304 KB Output is partially correct
12 Correct 22 ms 312 KB Output is correct
13 Partially correct 191 ms 292 KB Output is partially correct
14 Partially correct 71 ms 316 KB Output is partially correct
15 Partially correct 63 ms 320 KB Output is partially correct
16 Partially correct 68 ms 360 KB Output is partially correct
17 Partially correct 87 ms 312 KB Output is partially correct
18 Partially correct 85 ms 364 KB Output is partially correct
19 Partially correct 65 ms 312 KB Output is partially correct
20 Partially correct 73 ms 304 KB Output is partially correct
21 Partially correct 66 ms 312 KB Output is partially correct
22 Partially correct 45 ms 312 KB Output is partially correct
23 Partially correct 33 ms 320 KB Output is partially correct
24 Correct 27 ms 308 KB Output is correct
25 Correct 40 ms 308 KB Output is correct
26 Correct 29 ms 348 KB Output is correct
27 Correct 43 ms 360 KB Output is correct
28 Correct 55 ms 312 KB Output is correct
29 Partially correct 27 ms 316 KB Output is partially correct
30 Partially correct 26 ms 320 KB Output is partially correct
31 Partially correct 69 ms 296 KB Output is partially correct
32 Partially correct 68 ms 312 KB Output is partially correct
33 Partially correct 81 ms 312 KB Output is partially correct
34 Partially correct 91 ms 316 KB Output is partially correct
35 Partially correct 27 ms 292 KB Output is partially correct
36 Partially correct 62 ms 304 KB Output is partially correct
37 Partially correct 99 ms 312 KB Output is partially correct
38 Partially correct 67 ms 308 KB Output is partially correct
39 Correct 59 ms 308 KB Output is correct
40 Correct 54 ms 300 KB Output is correct
41 Partially correct 51 ms 304 KB Output is partially correct
42 Partially correct 60 ms 328 KB Output is partially correct
43 Partially correct 39 ms 312 KB Output is partially correct
44 Partially correct 169 ms 312 KB Output is partially correct
45 Correct 26 ms 312 KB Output is correct
46 Correct 23 ms 208 KB Output is correct
47 Correct 30 ms 312 KB Output is correct
48 Correct 28 ms 304 KB Output is correct