답안 #796376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796376 2023-07-28T10:37:31 Z ln_e 드문 곤충 (IOI22_insects) C++17
48.13 / 100
177 ms 552 KB
    #include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho
    #include "insects.h"
    using ll=long long;
    using ld=long double;
    int const INF=1000000005;
    ll const LINF=1000000000000000005;
    ll const mod=1000000007;
    ld const PI=3.14159265359;
    ll const MAX_N=3e5+5;
    ld const EPS=0.00000001;
    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #define f first
    #define s second
    #define pb push_back
    #define mp make_pair
    #define endl '\n'
    #define sz(a) (int)a.size()
    #define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    using namespace std;
    int cnt=0,n,viz[2005],nwviz[2005];
    vector<ll>original;
    ll check(ll mx){
      vector<ll>v;
      for(ll i=0;i<n;i++)
        nwviz[i]=viz[i];
      for(ll i=0;i<n;i++){
         if(v.size()+original.size()==cnt*mx){
          for(ll i=0;i<n;i++)
        viz[i]=nwviz[i];
        for(auto it : v){
          original.pb(it);
        }
        return 0;
      }
        if(viz[i]){
          continue;
        }
        move_inside(i);
        ll x=press_button();
        if(x>mx){
          move_outside(i);
        }else {
          v.pb(i);
          nwviz[i]=1;
        }
        if(v.size()+original.size()==cnt*mx){
          for(ll i=0;i<n;i++)
        viz[i]=nwviz[i];
        for(auto it : v){
          original.pb(it);
        }
        return 0;
      }
      }
      //  cout<<mx<<' '<<v.size()<<' '<<original.size()<<endl;
      if(v.size()+original.size()==cnt*mx){
          for(ll i=0;i<n;i++)
        viz[i]=nwviz[i];
        for(auto it : v){
          original.pb(it);
        }
        return 0;
      }
      for(auto it : v){
        move_outside(it);
      }
      return 1;
    }
    int min_cardinality(int N) {
      vector<ll>v;
     v.pb(0);
     n=N;
     move_inside(0);
     cnt=1;
     viz[0]=1;
     for(ll i=1;i<N;i++){
      move_inside(i);
      ll x=press_button();
      if(x>1){
        move_outside(i);
      }else {
        v.pb(i);
        viz[i]=1;
        cnt++;
      }
     }
     original=v;
     ll l=2,r=N-v.size()+1,ans=1;
     while(l<=r){
      ll mid=(l+r)/2;
      if(check(mid)==0){
        ans=mid;
        l=mid+1;
      }else r=mid-1;
     }
     return ans;
   }

Compilation message

insects.cpp: In function 'll check(ll)':
insects.cpp:28:37: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   28 |          if(v.size()+original.size()==cnt*mx){
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
insects.cpp:47:36: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   47 |         if(v.size()+original.size()==cnt*mx){
      |            ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
insects.cpp:57:34: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   57 |       if(v.size()+original.size()==cnt*mx){
      |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 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 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
9 Correct 6 ms 304 KB Output is correct
10 Correct 12 ms 208 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 15 ms 208 KB Output is correct
13 Correct 12 ms 308 KB Output is correct
14 Correct 10 ms 208 KB Output is correct
15 Correct 9 ms 308 KB Output is correct
16 Correct 7 ms 208 KB Output is correct
17 Correct 8 ms 208 KB Output is correct
18 Correct 9 ms 220 KB Output is correct
19 Correct 10 ms 304 KB Output is correct
20 Correct 10 ms 304 KB Output is correct
21 Correct 6 ms 208 KB Output is correct
22 Correct 4 ms 208 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 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
9 Correct 6 ms 304 KB Output is correct
10 Correct 12 ms 208 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 15 ms 208 KB Output is correct
13 Correct 12 ms 308 KB Output is correct
14 Correct 10 ms 208 KB Output is correct
15 Correct 9 ms 308 KB Output is correct
16 Correct 7 ms 208 KB Output is correct
17 Correct 8 ms 208 KB Output is correct
18 Correct 9 ms 220 KB Output is correct
19 Correct 10 ms 304 KB Output is correct
20 Correct 10 ms 304 KB Output is correct
21 Correct 6 ms 208 KB Output is correct
22 Correct 4 ms 208 KB Output is correct
23 Correct 20 ms 308 KB Output is correct
24 Correct 7 ms 308 KB Output is correct
25 Correct 27 ms 320 KB Output is correct
26 Correct 70 ms 296 KB Output is correct
27 Correct 56 ms 208 KB Output is correct
28 Correct 46 ms 312 KB Output is correct
29 Correct 84 ms 308 KB Output is correct
30 Correct 76 ms 208 KB Output is correct
31 Correct 39 ms 304 KB Output is correct
32 Correct 38 ms 304 KB Output is correct
33 Correct 43 ms 308 KB Output is correct
34 Correct 49 ms 328 KB Output is correct
35 Correct 49 ms 308 KB Output is correct
36 Correct 40 ms 304 KB Output is correct
37 Correct 50 ms 308 KB Output is correct
38 Correct 47 ms 552 KB Output is correct
39 Correct 56 ms 312 KB Output is correct
40 Correct 47 ms 320 KB Output is correct
41 Correct 23 ms 316 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 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 34 ms 300 KB Output is correct
8 Correct 13 ms 336 KB Output is correct
9 Partially correct 77 ms 320 KB Output is partially correct
10 Partially correct 114 ms 328 KB Output is partially correct
11 Partially correct 116 ms 296 KB Output is partially correct
12 Partially correct 79 ms 312 KB Output is partially correct
13 Partially correct 160 ms 328 KB Output is partially correct
14 Partially correct 97 ms 308 KB Output is partially correct
15 Partially correct 38 ms 428 KB Output is partially correct
16 Partially correct 86 ms 328 KB Output is partially correct
17 Partially correct 85 ms 328 KB Output is partially correct
18 Partially correct 101 ms 416 KB Output is partially correct
19 Partially correct 120 ms 288 KB Output is partially correct
20 Partially correct 84 ms 324 KB Output is partially correct
21 Partially correct 131 ms 304 KB Output is partially correct
22 Partially correct 129 ms 324 KB Output is partially correct
23 Partially correct 127 ms 316 KB Output is partially correct
24 Partially correct 101 ms 336 KB Output is partially correct
25 Partially correct 51 ms 448 KB Output is partially correct
26 Partially correct 58 ms 332 KB Output is partially correct
27 Partially correct 117 ms 328 KB Output is partially correct
28 Partially correct 56 ms 300 KB Output is partially correct
29 Partially correct 98 ms 352 KB Output is partially correct
30 Partially correct 110 ms 288 KB Output is partially correct
31 Partially correct 131 ms 424 KB Output is partially correct
32 Partially correct 151 ms 328 KB Output is partially correct
33 Partially correct 177 ms 328 KB Output is partially correct
34 Partially correct 116 ms 324 KB Output is partially correct
35 Partially correct 96 ms 300 KB Output is partially correct
36 Partially correct 100 ms 300 KB Output is partially correct
37 Partially correct 102 ms 364 KB Output is partially correct
38 Partially correct 144 ms 332 KB Output is partially correct
39 Partially correct 98 ms 328 KB Output is partially correct
40 Partially correct 99 ms 300 KB Output is partially correct
41 Partially correct 96 ms 300 KB Output is partially correct
42 Partially correct 80 ms 512 KB Output is partially correct
43 Partially correct 43 ms 208 KB Output is partially correct
44 Partially correct 168 ms 328 KB Output is partially correct
45 Correct 19 ms 328 KB Output is correct
46 Partially correct 79 ms 356 KB Output is partially correct
47 Partially correct 86 ms 316 KB Output is partially correct
48 Partially correct 73 ms 336 KB Output is partially correct