제출 #201171

#제출 시각아이디문제언어결과실행 시간메모리
201171rzbtDrvca (COCI19_drvca)C++14
0 / 110
45 ms2420 KiB
#include <bits/stdc++.h> #define MAXN 100005 #define pb push_back #define mp make_pair #define all(x) x.begin(),x.end() using namespace std; int n; int visine[MAXN]; vector<int> a,b; bool provera(){ if(b.empty()){ b.pb(a.back()); a.pop_back(); return true; } for(int i=2;i<b.size();i++){ if(b[i]-b[i-1]!=b[i-1]-b[i-2])return false; } return true; } void ispis(){ printf("%d\n",a.size()); for(auto x:a)printf("%d ",x); printf("\n%d\n",b.size()); for(auto x:b)printf("%d ",x); exit(0); } int main() { scanf("%d", &n); for(int i=0;i<n;i++)scanf("%d",visine+i); if(n==2){ printf("1\n%d\n1\n%d\n",visine[1],visine[0]); return 0; } sort(visine,visine+n); a.pb(visine[0]); a.pb(visine[1]); for(int i=2;i<n;i++){ if(visine[i]-a.back()==a.back()-a[a.size()-2])a.pb(visine[i]); else b.pb(visine[i]); } if(provera())ispis(); a.clear(); b.clear(); /// ///////////////////// a.pb(visine[0]); a.pb(visine[2]); b.pb(visine[1]); for(int i=3;i<n;i++){ if(visine[i]-a.back()==a.back()-a[a.size()-2])a.pb(visine[i]); else b.pb(visine[i]); } if(provera())ispis(); a.clear(); b.clear(); /// ///////////////////// a.pb(visine[1]); a.pb(visine[2]); b.pb(visine[0]); for(int i=3;i<n;i++){ if(visine[i]-a.back()==a.back()-a[a.size()-2])a.pb(visine[i]); else b.pb(visine[i]); } if(provera())ispis(); a.clear(); b.clear(); printf("-1"); return 0; }

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

drvca.cpp: In function 'bool provera()':
drvca.cpp:18:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=2;i<b.size();i++){
                 ~^~~~~~~~~
drvca.cpp: In function 'void ispis()':
drvca.cpp:24:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",a.size());
                   ~~~~~~~~^
drvca.cpp:26:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("\n%d\n",b.size());
                     ~~~~~~~~^
drvca.cpp: In function 'int main()':
drvca.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
drvca.cpp:35:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%d",visine+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...