답안 #723501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723501 2023-04-14T01:45:15 Z LittleFlowers__ 드문 곤충 (IOI22_insects) C++17
71.22 / 100
133 ms 468 KB
#include<bits/stdc++.h>
#include "insects.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;}
#define in hmt()
#define ins ({string x;char c=getchar();for(;c==' '||c=='\n';c=getchar());for(;c!=' '&&c!='\n';c=getchar()) x+=c;x;})
#define forinc(i,a,b) for(int i=a,_b=b;i<=_b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forb(i,BS) for(int i=BS._Find_first();i< BS.size();i = BS._Find_next(i))
#define timer 1.0*clock()/CLOCKS_PER_SEC
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
int n,m,dd[2010],T=40;
vector<int> a;
/*void move_inside(int i) {cout<<"i "<<i<<endl;}
void move_outside(int i) {cout<<"o "<<i<<endl;}
int press_button() {cout<<"g\n";int x;cin>>x;return x;}*/
int calc(int l,int r,vector<int> e) {
    if(l==r) return e.size()+1;
    int m=(l+r)/2;
    forinc(i,l,m) move_inside(a[i]);
    vector<int> L,R;
    forv(x,e) {
        move_inside(x);
        if(press_button()>1) L.pb(x);
        else R.pb(x);
        move_outside(x);
    }
    forinc(i,l,m) move_outside(a[i]);
    return min(calc(l,m,L),calc(m+1,r,R));
}
bool check(int x) {
    vector<int> e;
    int cnt=m;
    forinc(i,0,n-1) if(!dd[i]) {
        move_inside(i);
        if(press_button()>x+1) {
            move_outside(i);
        } else {
            ++cnt;
            e.pb(i);
        }
    }
    forv(i,e) move_outside(i);
    return cnt<m*(x+1);
}
int min_cardinality(int N) {
    n=N;
    a.clear();
    a.pb(0);
    move_inside(0);
    forinc(i,1,n-1) {
        move_inside(i);
        if(press_button()>1) move_outside(i);
        else a.pb(i);
    }
    reset(dd,0);
    forv(i,a) {
        dd[i]=1;
    }
    m=a.size();
    if(m<=T) {
        forv(i,a) forv(i,a) move_outside(i);
        vector<int> e;
        forinc(i,0,n-1) if(!dd[i]) e.pb(i);
        return calc(0,m-1,e);
    } else {
        int l=1,r=n/m,ret;
        while(l<=r) {
            int mid=(l+r)/2;
            if(check(mid)) ret=mid,r=mid-1;
            else l=mid+1;
        }
        return ret;
    }
}
/*int main() {
    cout<<min_cardinality(5);
}*/

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:73:14: warning: unused variable 'i' [-Wunused-variable]
   73 |         forv(i,a) forv(i,a) move_outside(i);
      |              ^
insects.cpp:13:29: note: in definition of macro 'forv'
   13 | #define forv(a,b) for(auto &a:b)
      |                             ^
insects.cpp:78:23: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   78 |         int l=1,r=n/m,ret;
      |                       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
9 Correct 7 ms 308 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 7 ms 208 KB Output is correct
13 Correct 9 ms 208 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 9 ms 208 KB Output is correct
16 Correct 9 ms 308 KB Output is correct
17 Correct 9 ms 208 KB Output is correct
18 Correct 11 ms 300 KB Output is correct
19 Correct 10 ms 208 KB Output is correct
20 Correct 6 ms 208 KB Output is correct
21 Correct 4 ms 208 KB Output is correct
22 Correct 3 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
9 Correct 7 ms 308 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 7 ms 208 KB Output is correct
13 Correct 9 ms 208 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 9 ms 208 KB Output is correct
16 Correct 9 ms 308 KB Output is correct
17 Correct 9 ms 208 KB Output is correct
18 Correct 11 ms 300 KB Output is correct
19 Correct 10 ms 208 KB Output is correct
20 Correct 6 ms 208 KB Output is correct
21 Correct 4 ms 208 KB Output is correct
22 Correct 3 ms 304 KB Output is correct
23 Correct 6 ms 296 KB Output is correct
24 Correct 10 ms 208 KB Output is correct
25 Correct 61 ms 308 KB Output is correct
26 Correct 58 ms 324 KB Output is correct
27 Correct 17 ms 300 KB Output is correct
28 Correct 17 ms 288 KB Output is correct
29 Correct 32 ms 300 KB Output is correct
30 Correct 57 ms 300 KB Output is correct
31 Correct 47 ms 304 KB Output is correct
32 Correct 48 ms 208 KB Output is correct
33 Correct 50 ms 304 KB Output is correct
34 Correct 47 ms 304 KB Output is correct
35 Correct 48 ms 208 KB Output is correct
36 Correct 28 ms 320 KB Output is correct
37 Correct 39 ms 284 KB Output is correct
38 Correct 34 ms 208 KB Output is correct
39 Correct 20 ms 208 KB Output is correct
40 Correct 16 ms 312 KB Output is correct
41 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 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 1 ms 208 KB Output is correct
7 Correct 14 ms 284 KB Output is correct
8 Correct 17 ms 208 KB Output is correct
9 Partially correct 87 ms 388 KB Output is partially correct
10 Partially correct 132 ms 208 KB Output is partially correct
11 Correct 43 ms 288 KB Output is correct
12 Correct 18 ms 312 KB Output is correct
13 Partially correct 71 ms 328 KB Output is partially correct
14 Partially correct 61 ms 312 KB Output is partially correct
15 Partially correct 90 ms 280 KB Output is partially correct
16 Partially correct 46 ms 348 KB Output is partially correct
17 Partially correct 79 ms 280 KB Output is partially correct
18 Partially correct 91 ms 328 KB Output is partially correct
19 Partially correct 52 ms 468 KB Output is partially correct
20 Partially correct 98 ms 336 KB Output is partially correct
21 Partially correct 113 ms 420 KB Output is partially correct
22 Partially correct 108 ms 292 KB Output is partially correct
23 Partially correct 77 ms 288 KB Output is partially correct
24 Correct 49 ms 208 KB Output is correct
25 Correct 29 ms 340 KB Output is correct
26 Correct 27 ms 304 KB Output is correct
27 Partially correct 133 ms 284 KB Output is partially correct
28 Partially correct 90 ms 332 KB Output is partially correct
29 Partially correct 99 ms 308 KB Output is partially correct
30 Partially correct 102 ms 428 KB Output is partially correct
31 Partially correct 79 ms 292 KB Output is partially correct
32 Partially correct 117 ms 292 KB Output is partially correct
33 Partially correct 61 ms 420 KB Output is partially correct
34 Partially correct 95 ms 284 KB Output is partially correct
35 Partially correct 107 ms 304 KB Output is partially correct
36 Partially correct 107 ms 304 KB Output is partially correct
37 Partially correct 86 ms 308 KB Output is partially correct
38 Partially correct 95 ms 400 KB Output is partially correct
39 Partially correct 118 ms 308 KB Output is partially correct
40 Partially correct 101 ms 308 KB Output is partially correct
41 Partially correct 102 ms 392 KB Output is partially correct
42 Partially correct 119 ms 284 KB Output is partially correct
43 Partially correct 18 ms 440 KB Output is partially correct
44 Partially correct 59 ms 348 KB Output is partially correct
45 Correct 30 ms 320 KB Output is correct
46 Correct 29 ms 296 KB Output is correct
47 Correct 34 ms 292 KB Output is correct
48 Correct 30 ms 296 KB Output is correct