제출 #307655

#제출 시각아이디문제언어결과실행 시간메모리
307655vivaan_gupta버섯 세기 (IOI20_mushrooms)C++14
컴파일 에러
0 ms0 KiB
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <ratio> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #include <climits> // #include "mushrooms.h" #define ll long long #define ld long double #define mp make_pair #define pb push_back #define in insert #define vll vector<ll> #define endl "\n" #define pll pair<ll,ll> #define f first #define s second #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++) // #define int ll #define sz(x) (ll)x.size() #define all(x) (x.begin(),x.end()) using namespace std; const ll INF = 1e12; const ll N =(1e5+5); // TODO : change value as per problem const ll MOD = 1e9+7; int a[N]; int use_machine(vector<int> v){ int d= 0 ; for(int i =0 ;i<v.size()-1;i++){ d+=(a[v[i]]!=a[v[i+1]]); } return d; } int count_mushrooms(int n){ int B =0; for(int i = 0;i<(n-1);i+=2){ vector<int> v; v.pb(i),v.pb(i+1); int x= use_machine(v); if(x == 0){ vector<int> tmp = {0,i}; if(use_machine(tmp) == 1) B += 2; continue; } B+=1; } vector<int> v; if(n&1){ v.pb(0); v.pb(n-1); B += use_machine(v); } return n-B; } signed main(){ int n; cin >> n; for(int i = 0;i<n;i++){ cin >> a[i]; } cout << count_mushrooms(n) << endl; } // signed main(){ // ios_base::sync_with_stdio(0); // cin.tie(NULL); // // freopen(".in","r",stdin);freopen(".out","w",stdout); // ll tt=1; // // cin >> tt; // while(tt--){ // solve(); // } // }

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

mushrooms.cpp: In function 'int use_machine(std::vector<int>)':
mushrooms.cpp:55:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for(int i =0 ;i<v.size()-1;i++){
      |                ~^~~~~~~~~~~
/tmp/cc01HFUH.o: In function `use_machine(std::vector<int, std::allocator<int> >)':
stub.cpp:(.text+0x200): multiple definition of `use_machine(std::vector<int, std::allocator<int> >)'
/tmp/cc66hx5t.o:mushrooms.cpp:(.text+0x0): first defined here
/tmp/cc01HFUH.o: In function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc66hx5t.o:mushrooms.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status