제출 #409459

#제출 시각아이디문제언어결과실행 시간메모리
409459dualityPark (JOI17_park)C++11
20 / 100
604 ms668 KiB
#define DEBUG 0 #include <bits/stdc++.h> using namespace std; #if DEBUG // basic debugging macros int __i__,__j__; #define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl #define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl #define printVar(n) cout<<#n<<": "<<n<<endl #define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl #define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;} #define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;} // advanced debugging class // debug 1,2,'A',"test"; class _Debug { public: template<typename T> _Debug& operator,(T val) { cout << val << endl; return *this; } }; #define debug _Debug(), #else #define printLine(l) #define printLine2(l,c) #define printVar(n) #define printArr(a,l) #define print2dArr(a,r,c) #define print2dArr2(a,r,c,l) #define debug #endif // define #define MAX_VAL 999999999 #define MAX_VAL_2 999999999999999999LL #define EPS 1e-6 #define mp make_pair #define pb push_back // typedef typedef unsigned int UI; typedef long long int LLI; typedef unsigned long long int ULLI; typedef unsigned short int US; typedef pair<int,int> pii; typedef pair<LLI,LLI> plli; typedef vector<int> vi; typedef vector<LLI> vlli; typedef vector<pii> vpii; typedef vector<plli> vplli; // ---------- END OF TEMPLATE ---------- #include "park.h" int P[1400]; int ask(int A,int B,int *P) { if (A > B) swap(A,B); return Ask(A,B,P); } int answer(int A,int B) { if (A > B) swap(A,B); Answer(A,B); return 0; } int solve(vi v,int N) { if (v.size() == 1) return 0; else if (v.size() == 2) { answer(v[0],v[1]); return 0; } int i,j; vi c,com[7]; swap(v[0],v[rand() % v.size()]); for (i = 1; i < v.size(); i++) { fill(P,P+N,0); P[v[0]] = P[v[i]] = 1; if (ask(v[0],v[i],P)) c.pb(v[i]),answer(v[0],v[i]); } for (i = 1; i < v.size(); i++) { for (j = 0; j < c.size(); j++) { if (c[j] == v[i]) break; } if (j == c.size()) { fill(P,P+N,0); for (j = 0; j < v.size(); j++) P[v[j]] = 1; int l = 0,r = c.size()-1; while (l < r) { int m = (l+r) / 2; for (j = l; j <= m; j++) P[c[j]] = 0; if (ask(v[0],v[i],P)) l = m+1; else r = m; for (j = l; j <= m; j++) P[c[j]] = 1; } com[l].pb(v[i]); } else com[j].pb(v[i]); } for (i = 0; i < c.size(); i++) solve(com[i],N); return 0; } void Detect(int T,int N) { if (T == 1) { int i,j,k; for (i = 0; i < N; i++) { for (j = i+1; j < N; j++) { for (k = 0; k < N; k++) P[k] = 0; P[i] = P[j] = 1; if (ask(i,j,P)) answer(i,j); } } } else { int i; vi v; for (i = 0; i < N; i++) v.pb(i); solve(v,N); } }

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

park.cpp: In function 'int solve(vi, int)':
park.cpp:79:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     for (i = 1; i < v.size(); i++) {
      |                 ~~^~~~~~~~~~
park.cpp:84:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |     for (i = 1; i < v.size(); i++) {
      |                 ~~^~~~~~~~~~
park.cpp:85:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |         for (j = 0; j < c.size(); j++) {
      |                     ~~^~~~~~~~~~
park.cpp:88:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |         if (j == c.size()) {
      |             ~~^~~~~~~~~~~
park.cpp:90:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |             for (j = 0; j < v.size(); j++) P[v[j]] = 1;
      |                         ~~^~~~~~~~~~
park.cpp:104:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  104 |     for (i = 0; i < c.size(); i++) solve(com[i],N);
      |                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...