제출 #1015853

#제출 시각아이디문제언어결과실행 시간메모리
1015853Ahmed_Solyman카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
/* In the name of Allah made by: Ahmed_Solyman */ #include <bits/stdc++.h> #include <ext/rope> using namespace std; using namespace __gnu_cxx; #pragma GCC optimize("-Ofast") #pragma GCC optimize("-O1") //-------------------------------------------------------------// typedef long long ll; typedef unsigned long long ull; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define PI acos(-1) #define lb lower_bound #define ub upper_bound #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() #define sum_to(n) (n*(n+1))/2 #define pb push_back #define pf push_front #define fil(arr,x) memset(arr,x,sizeof(arr)) #define endl '\n' const ll mod=1e9+7; int dx[8]={0,1,0,-1,1,1,-1,-1}; int dy[8]={1,0,-1,0,1,-1,-1,1}; //-------------------------------------------------------------// ll lcm(ll a,ll b) { return (max(a,b)/__gcd(a,b))*min(a,b); } void person_bool(bool x) { cout<<(x?"YES":"NO")<<endl; } void allocate_tickets(vector<vector<int>>s); ll find_maximum(int k,vector<vector<int>>v){ int n=(int)v.size(); int m=(int)v[0].size(); vector<vector<int>>g(n,vector<int>(m,0)); vector<array<int,2>>p; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ p.push_back({v[i][j],i}); } } sort(allr(p)); ll ret=0; vector<int>cnt(n); vector<int>v1[n],v2[n]; for(int i=0;i<n*m;i++){ if(i<n*m/2)ret+=p[i][0],cnt[p[i][1]]++,v1[p[i][1]].push_back(p[i][2]); else ret-=p[i][0],v2[p[i][1]].push_back(p[i][2]); } int cnt=0; while(m--){ vector<pair<int,int>>d; for(int i=0;i<n;i++)d.push_back({cnt[i],i}); sort(allr(d)); for(int i=0;i<n;i++){ int j=d[i].second; if(i<n/2){ g[j][v1[j].back()]=cnt; v1[j].pop_back(); cnt[j]--; } else{ g[j][v2[j].back()]=cnt; v2[j].pop_back(); } } cnt++; } allocate_tickets(g); return ret; }

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

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:58:9: error: conflicting declaration 'int cnt'
   58 |     int cnt=0;
      |         ^~~
tickets.cpp:52:16: note: previous declaration as 'std::vector<int> cnt'
   52 |     vector<int>cnt(n);
      |                ^~~
tickets.cpp:66:36: error: cannot convert 'std::vector<int>' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} in assignment
   66 |                 g[j][v1[j].back()]=cnt;
      |                                    ^~~
      |                                    |
      |                                    std::vector<int>
tickets.cpp:71:36: error: cannot convert 'std::vector<int>' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} in assignment
   71 |                 g[j][v2[j].back()]=cnt;
      |                                    ^~~
      |                                    |
      |                                    std::vector<int>
tickets.cpp:75:12: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
   75 |         cnt++;
      |         ~~~^~