Submission #486643

#TimeUsernameProblemLanguageResultExecution timeMemory
486643cheissmartMinerals (JOI19_minerals)C++14
100 / 100
48 ms3980 KiB
#include "minerals.h" #include <bits/stdc++.h> #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define MP make_pair #define EB emplace_back #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m"; void DBG() { cerr << "]" << _reset << endl; } template<class H, class...T> void DBG(H h, T ...t) { cerr << to_string(h); if(sizeof ...(t)) cerr << ", "; DBG(t...); } #ifdef CHEISSMART #define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) #else #define debug(...) #endif const int INF = 1e9 + 7; int now; bool isin(int i) { int pre = now; now = Query(i); return pre == now; } void solve(vi a, vi b, int n, bool in) { assert(int(a.size()) == n); assert(int(b.size()) == n); if(n == 1) { Answer(a[0], b[0]); return; } int m = max(1, int(0.382 * n)); vi al, bl, ar, br; for(int i = 0; i < m; i++) { now = Query(a[i]); al.PB(a[i]); } for(int i = m; i < n; i++) ar.PB(a[i]); for(int i:b) { if(int(bl.size() == m)) br.PB(i); else if(int(br.size()) == n - m) bl.PB(i); else { if(isin(i)) { if(in) br.PB(i); else bl.PB(i); } else { if(in) bl.PB(i); else br.PB(i); } } } solve(al, bl, m, !in); solve(ar, br, n - m, in); } void Solve(int n) { int pre = 0; vi a, b; for(int i = 1; i <= 2 * n; i++) { now = Query(i); if(pre == now) a.PB(i); else b.PB(i); pre = now; } solve(a, b, n, true); }

Compilation message (stderr)

minerals.cpp: In function 'void solve(vi, vi, int, bool)':
minerals.cpp:57:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |   if(int(bl.size() == m)) br.PB(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...
#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...