제출 #484728

#제출 시각아이디문제언어결과실행 시간메모리
484728AmirElarbi버섯 세기 (IOI20_mushrooms)C++14
컴파일 에러
0 ms0 KiB
//#include "mushrooms.h" #include <bits/stdc++.h> #define vi vector<int> #define ve vector #define ll long long #define vf vector<float> #define vll vector<pair<ll,ll>> #define ii pair<int,int> #define vvi vector<vi> #define vii vector<ii> #define gii greater<ii> #define pb push_back #define fi first #define se second #define INF 1e7 #define eps 1e-18 #define eps1 1e-25 #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL); #define MAX_A 1e5+5 #define V 450 using namespace std; const int MOD = 1e9+7; const int nax = 2000005; string s; int use_machine(vector<int> a){ int cnt = 0; for(int i = 0;i<((int)a.size())-1;i++){ if(s[a[i]] != s[a[i+1]])cnt++; } return cnt; } int count_mushrooms(int n) { int X = 279; vi typ[2]; typ[0].pb(0); for(int i = 1; i <= 2; i++){ typ[use_machine({0,i})].pb(i); } bool B = false; if(typ[1].size() == 2) B = true; for (int i = 3; i <= min(n-2,X); i+=2) { int res = 0; if(B){ res = use_machine({typ[1][0],i,typ[1][1], i+1}); } else{ res = use_machine({typ[0][0],i,typ[0][1], i+1}); } if(res == 0){ typ[B^1].pb(i); typ[B^1].pb(i+1); } else if(res == 1){ typ[B^1].pb(i); typ[B].pb(i+1); } else if(res == 2){ typ[B].pb(i); typ[B^1].pb(i+1); } else { typ[B].pb(i); typ[B].pb(i+1); } } if(n%2 == 0 && n-2 < X){ typ[use_machine({0,n-1})].pb(n-1); } int cnt = typ[0].size(); for (int i = 280; i < n; i+=280) { vi a; for(int j = i; j < i+typ[0].size() && j < n;j++){ a.pb(typ[0][j-i]); a.pb(j); } int res = use_machine(a); cnt += min((int) typ[0].size(),n-i)-((res+1)/2); res = 0; a.clear(); for(int j = i+typ[0].size(); j < i+280 && j < n;j++){ a.pb(typ[1][j-i-typ[0].size()]); a.pb(j); } if(a.size()) res = use_machine(a); cnt += ((res+1)/2); } return cnt; } int main(){ s = "ABAA"; cout << count_mushrooms(s.size()) << endl; //} }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:79:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |         for(int j = i; j < i+typ[0].size() && j < n;j++){
      |                        ~~^~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccTieU4b.o: in function `use_machine(std::vector<int, std::allocator<int> >)':
stub.cpp:(.text+0x210): multiple definition of `use_machine(std::vector<int, std::allocator<int> >)'; /tmp/ccCjWC6c.o:mushrooms.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccTieU4b.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccCjWC6c.o:mushrooms.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status