제출 #755143

#제출 시각아이디문제언어결과실행 시간메모리
755143Rafi22드문 곤충 (IOI22_insects)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> //#include "insects.h" using namespace std; #define endl '\n' #define st first #define nd second #define pb push_back #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define ll long long ll mod=1000000007; int inf=1000000007; ll infl=1000000000000000007; int ans=1,m; int DP[2007]; int co[2007]; /* int a[107]; map<int,int>ile; set<int>W; void move_inside(int i) { W.insert(i); } void move_outside(int i) { W.erase(i); } int press_button() { ile.clear(); int ans=0; for(auto x:W) ans=max(ans,++ile[a[x]]); return ans; } */ void rek(vector<int>a) { if(sz(a)<m) return ; int k=co[sz(a)]; vector<int>T,N; bool is=0; for(auto x:a) { move_inside(x); if(press_button()>ans+k) { move_outside(x); N.pb(x); } else T.pb(x); } if(sz(T)==m*k) { ans+=k; rek(N); } else { for(auto x:T) move_outside(x); rek(T); } } int min_cardinality(int n) { vector<int>V,X; for(int i=0;i<n;i++) { move_inside(i); if(press_button()>1) { move_outside(i); V.pb(i); } else { X.pb(i); m++; } } for(int i=m;i<=n;i++) { DP[i]=inf; for(int k=1;k*m<=i;k++) { if(max(DP[i-m*k],DP[m*k-1])+i<DP[i]) { co[i]=k; DP[i]=max(DP[i-m*k],DP[m*k-1])+i; } } } rek(V); return ans; } /* int main() { int n; cin>>n; for(int i=0;i<n;i++) cin>>a[i]; cout<<min_cardinality(n)<<endl; return 0; } /* 6 5 8 9 5 9 9 */

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp:111:1: warning: "/*" within comment [-Wcomment]
  111 | /*
      |  
insects.cpp: In function 'void rek(std::vector<int>)':
insects.cpp:50:9: error: 'move_inside' was not declared in this scope
   50 |         move_inside(x);
      |         ^~~~~~~~~~~
insects.cpp:51:12: error: 'press_button' was not declared in this scope
   51 |         if(press_button()>ans+k)
      |            ^~~~~~~~~~~~
insects.cpp:53:13: error: 'move_outside' was not declared in this scope
   53 |             move_outside(x);
      |             ^~~~~~~~~~~~
insects.cpp:65:23: error: 'move_outside' was not declared in this scope
   65 |         for(auto x:T) move_outside(x);
      |                       ^~~~~~~~~~~~
insects.cpp:47:10: warning: unused variable 'is' [-Wunused-variable]
   47 |     bool is=0;
      |          ^~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:75:9: error: 'move_inside' was not declared in this scope
   75 |         move_inside(i);
      |         ^~~~~~~~~~~
insects.cpp:76:12: error: 'press_button' was not declared in this scope
   76 |         if(press_button()>1)
      |            ^~~~~~~~~~~~
insects.cpp:78:13: error: 'move_outside' was not declared in this scope
   78 |             move_outside(i);
      |             ^~~~~~~~~~~~