제출 #384968

#제출 시각아이디문제언어결과실행 시간메모리
384968Ahmadsm2005카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "grader.cpp"
//#include "tickets.h"
using namespace std;
long long find_maximum(int k,vector<vector<int>> x) {
int n = x.size();
long long CNT=0;
int m = x[0].size();
vector<vector<int>>answer(n);
for(int i=0;i<n;i++)
for(int l=0;l<m;l++)
answer[i].push_back(-1);
set<pair<int,pair<int,int>>>lol;
set<int>VIS;
vector<pair<int,pair<int,int>>>TEMP,TEMP2;
for(int i=0;i<n;i++){
for(int l=0;l<m;l++){
lol.insert({x[i][l],{i,l}});
}
}
int Z=0;
int N=n;
while(N){
auto itr=lol.end(),itr2=lol.begin();
itr--;
while(VIS.find((itr->second).first)!=VIS.end())
itr--;
VIS.insert((itr->second).first);
while(VIS.find((itr2->second).first)!=VIS.end())
itr2++;
TEMP.push_back({(itr->first),{(itr->second).first,(itr->second).second}});
TEMP.push_back({(itr2->first),{(itr2->second).first,(itr2->second).second}});
VIS.insert((itr2->second).first);
lol.erase(itr),lol.erase(itr2);
N-=2;
}
Z++;
sort(TEMP.begin(),TEMP.end());
int X=TEMP[(TEMP.size()-1)/2].first;
for(int i=0;i<TEMP.size();i++){
CNT+=abs(TEMP[i].first-X);
}
long long MAXER=CNT;
CNT=0;
for(int i=0;i<n;i++){
for(int l=0;l<m;l++){
lol.insert({x[i][l],{i,l}});
}
}
VIS.clear();
Z=0;
N=n;
while(N){
auto itr=lol.end(),itr2=lol.begin();
itr--;
while(VIS.find((itr2->second).first)!=VIS.end())
itr2++;
VIS.insert((itr2->second).first);
while(VIS.find((itr->second).first)!=VIS.end())
itr--;
TEMP2.push_back({(itr->first),{(itr->second).first,(itr->second).second}});
TEMP2.push_back({(itr2->first),{(itr2->second).first,(itr2->second).second}});
VIS.insert((itr2->second).first);
lol.erase(itr),lol.erase(itr2);
N-=2;
}
Z++;
sort(TEMP2.begin(),TEMP2.end());
X=TEMP2[(TEMP2.size()-1)/2].first;
for(int i=0;i<TEMP2.size();i++){
CNT+=abs(TEMP2[i].first-X);
}
//cout<<MAXER<<' '<<CNT<<endl;
if(MAXER<CNT){
TEMP=TEMP2;
MAXER=CNT;
}
for(int i=0;i<TEMP.size();i++)
answer[TEMP[i].second.first][TEMP[i].second.second]=0;
allocate_tickets(answer);
return MAXER;
}

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:40:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 | for(int i=0;i<TEMP.size();i++){
      |             ~^~~~~~~~~~~~
tickets.cpp:70:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 | for(int i=0;i<TEMP2.size();i++){
      |             ~^~~~~~~~~~~~~
tickets.cpp:78:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 | for(int i=0;i<TEMP.size();i++)
      |             ~^~~~~~~~~~~~
/tmp/ccRQWKXp.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccCCR0SE.o:tickets.cpp:(.text.startup+0x0): first defined here
/tmp/ccRQWKXp.o: In function `allocate_tickets(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)':
grader.cpp:(.text+0x1f0): multiple definition of `allocate_tickets(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
/tmp/ccCCR0SE.o:tickets.cpp:(.text+0x1f0): first defined here
collect2: error: ld returned 1 exit status