제출 #701858

#제출 시각아이디문제언어결과실행 시간메모리
701858Darren0724The Potion of Great Power (CEOI20_potion)C++17
컴파일 에러
0 ms0 KiB
#include "grader.cpp" #include<bits/stdc++.h> using namespace std; int n; vector<int> h; struct cmp{ bool operator()(const int &a,const int &b)const{ if(h[a]==h[b]){ return a<b; } return h[a]<h[b]; } }; vector<map<int,vector<pair<int,int>>>> s; void init(int N, int D, int H[]) { n=N; h.resize(n); s.resize(n); for(int i=0;i<n;i++){ h[i]=H[i]; } } void curseChanges(int U, int A[], int B[]) { for(int i=1;i<=U;i++){ int a=A[i-1]; int b=B[i-1]; if(s[a].find(b)==s[a].end()){ s[a][b].push_back({i,1}); s[b][a].push_back({i,1}); } else{ s[a][b].push_back({i,0}); s[b][a].push_back({i,0}); } } } int question(int x, int y, int v) { int ans=1000000000; vector<int> a,b; for(pair<int,vector<pair<int,int>>> j:s[x]){ int tmp=(--upper_bound(j.second.begin(),j.second.end(),make_pair(v,10)))->second; if(tmp==1){ a.push_back(j.first); } } for(pair<int,vector<pair<int,int>>> j:s[y]){ int tmp=(--upper_bound(j.second.begin(),j.second.end(),make_pair(v,10)))->second; if(tmp==1){ b.push_back(j.first); } } sort(a.begin(),a.end(),cmp()); sort(b.begin(),b.end(),cmp()); int ptr1=0,ptr2=0; while(ptr1<a.size()&&ptr2<b.size()){ int a1=a[ptr1]; int b1=b[ptr2]; ans=min(ans,abs(h[a1]-h[b1])); if(h[a1]<h[b1]){ ptr1++; } else{ ptr2++; } } return ans; }

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

potion.cpp: In function 'int question(int, int, int)':
potion.cpp:58:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     while(ptr1<a.size()&&ptr2<b.size()){
      |           ~~~~^~~~~~~~~
potion.cpp:58:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     while(ptr1<a.size()&&ptr2<b.size()){
      |                          ~~~~^~~~~~~~~
/usr/bin/ld: /tmp/cc2VQRTi.o: in function `sigH(int)':
grader.cpp:(.text+0x0): multiple definition of `sigH(int)'; /tmp/ccrxOgmj.o:potion.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/cc2VQRTi.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccrxOgmj.o:potion.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status