제출 #1149626

#제출 시각아이디문제언어결과실행 시간메모리
1149626modwweCounting Mushrooms (IOI20_mushrooms)C++20
컴파일 에러
0 ms0 KiB
//#include "gap.h" //#include "mushrooms.h" #pragma GCC optimize("Ofast,unroll-loops") #include<bits/stdc++.h> //#define int long long #define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task2 "ftree" #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".out","w",stdout) #define pb push_back #define mask(k) (1<<k) #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; #define getchar_unlocked getchar mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l,int r) { return uniform_int_distribution<int>(l,r)(rd); } void phongbeo(); const int inf = 1e16; const ll mod2 = 1e9+7; const ll base=67; int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center; int i, s10, s12,k1,k2,k3,s11,lim,w,l,r ; int kk; int t; int el = 19;/* main() { if(fopen(task2".inp","r")) { fin(task2); fou(task2); } if(fopen(task".inp","r")) { fin(task); fou(task); } ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); /// cin>>s1; //int t;cin>>t; while(t--) phongbeo(); // checktime }*/ vector<int> b,c,v; int a[20000]; /*int use_machine(vector<int> v) { dem2++; int s=0; for(int i=0; i<v.size()-1; i++) s+=(a[v[i]]!=a[v[i+1]]); return s; }*/ int count_mushrooms(int N) { n=N; if(n<=450){ int cnt=1; for(int i=1;i<n;i+=2){ vector<int> x={i}; x.push_back(0); if(i+1<n) x.push_back(i+1); cnt+=(int)x.size()-1-use_machine(x); } return cnt; } b.pb(0); for(int i=1; i<n; i++) v.pb(i); int s=0; shuffle(v.begin(),v.end(),rd); while(max(c.size(),b.size())<=122&&s<v.size()) { if(max(c.size(),b.size())==1||s==v.size()-1) { int x=use_machine({b[0],v[s]}); if(!x)b.pb(v[s]); else c.pb(v[s]); s++; } else { if(b.size()>=2) { int x=use_machine({b[0],v[s],b[1],v[s+1]}); if(!bit(x,0))b.pb(v[s+1]); else c.pb(v[s+1]); if(!bit(x,1))b.pb(v[s]); else c.pb(v[s]); } else { int x=use_machine({c[0],v[s],c[1],v[s+1]}); if(bit(x,0))b.pb(v[s+1]); else c.pb(v[s+1]); if(bit(x,1))b.pb(v[s]); else c.pb(v[s]); } s+=2; } } s4=0; while(s<v.size()) { if(b.size()>=c.size()) { vector<int> hihi; dem=0; s8=0; for(int i=0; i<b.size(); i++) { hihi.pb(b[i]); hihi.pb(v[s]); dem++; s++; if(s==v.size())break; } s7=use_machine(hihi); s4=s4+dem-(s7+1)/2; if(s7%2==0)b.pb(v[s-1]),s4--; else c.pb(v[s-1]); } else { vector<int> hihi; dem=0; for(int i=0; i<c.size(); i++) { hihi.pb(c[i]); hihi.pb(v[s]); s++; dem++; if(s==v.size())break; } s7=use_machine(hihi); if(s7%2==0)c.pb(v[s-1]); else b.pb(v[s-1]),s4--; s4=s4+(s7+1)/2; } } return s4+b.size(); } void phongbeo() { cin>>n; for(int i=0;i<n;i++) cin>>a[i]; /* for(int i=0; i<n; i++) a[i]=rand(0,1); a[0]=1;*/ for(int i=0; i<n; i++) s2+=(1-a[i]); s3=count_mushrooms(n); cout<<s3<<" "<<s2<<" "<<dem2,down }

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

mushrooms.cpp:27:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+16' to '2147483647' [-Woverflow]
   27 | const int inf = 1e16;
      |                 ^~~~
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:75:34: error: 'use_machine' was not declared in this scope
   75 |             cnt+=(int)x.size()-1-use_machine(x);
      |                                  ^~~~~~~~~~~
mushrooms.cpp:88:19: error: 'use_machine' was not declared in this scope
   88 |             int x=use_machine({b[0],v[s]});
      |                   ^~~~~~~~~~~
mushrooms.cpp:97:23: error: 'use_machine' was not declared in this scope
   97 |                 int x=use_machine({b[0],v[s],b[1],v[s+1]});
      |                       ^~~~~~~~~~~
mushrooms.cpp:105:23: error: 'use_machine' was not declared in this scope
  105 |                 int x=use_machine({c[0],v[s],c[1],v[s+1]});
      |                       ^~~~~~~~~~~
mushrooms.cpp:130:16: error: 'use_machine' was not declared in this scope
  130 |             s7=use_machine(hihi);
      |                ^~~~~~~~~~~
mushrooms.cpp:147:16: error: 'use_machine' was not declared in this scope
  147 |             s7=use_machine(hihi);
      |                ^~~~~~~~~~~