제출 #306813

#제출 시각아이디문제언어결과실행 시간메모리
306813dolijanDrvca (COCI19_drvca)C++14
0 / 110
108 ms3376 KiB
#include<bits/stdc++.h> using namespace std; const int mn=1e5+100; int a[mn]; bool check(int prvi,int drugi,int n) { vector<int> aa; vector<int> bb; aa.push_back(a[prvi]); aa.push_back(a[drugi]); for(int i=0;i<drugi;i++) { if(i!=prvi) bb.push_back(a[i]); } int raz=a[drugi]-a[prvi]; for(int i=drugi+1;i<n;i++) { int zad=aa[aa.size()-1]; if(a[i]-zad==raz) { aa.push_back(a[i]); } else { bb.push_back(a[i]); } } bool li=true; if((int)bb.size()==0) { bb.push_back(aa[aa.size()-1]); aa.pop_back(); } else if(bb.size()>=2) { int rzl=bb[1]-bb[0]; for(int i=1;i<bb.size();i++) { if(bb[i]-bb[i-1]!=rzl) li=false; } } if(li) { cout<<aa.size()<<endl; for(int i=0;i<aa.size();i++) cout<<aa[i]<<" "; cout<<endl; cout<<bb.size()<<endl; for(int i=0;i<bb.size();i++) cout<<bb[i]<<" "; cout<<endl; return true; } return false; } int main() { int n; cin>>n; for(int i=0;i<n;i++) cin>>a[i]; sort(a,a+n); if(n==2) { cout<<1<<endl; cout<<a[0]<<endl; cout<<1<<endl; cout<<a[1]<<endl; } else { if(!check(0,1,n)) { if(!check(0,2,n)) { if(!check(1,2,n)) { cout<<-1<<endl; } } } } }

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

drvca.cpp: In function 'bool check(int, int, int)':
drvca.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int i=1;i<bb.size();i++)
      |                     ~^~~~~~~~~~
drvca.cpp:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int i=0;i<aa.size();i++) cout<<aa[i]<<" ";
      |                     ~^~~~~~~~~~
drvca.cpp:48:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for(int i=0;i<bb.size();i++) cout<<bb[i]<<" ";
      |                     ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...