제출 #967180

#제출 시각아이디문제언어결과실행 시간메모리
967180Soumya1Minerals (JOI19_minerals)C++17
100 / 100
35 ms4268 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; int last = 0; bool ask(int x) { int nw = Query(x); bool g = (last != nw); last = nw; return g; } void solve(vector<int> a, vector<int> b, bool f) { if (a.size() == 1) { Answer(a[0], b[0]); return; } int n = a.size(); int mid = (int) max(1.0, n * 0.4); vector<int> la, lb, ra, rb; for (int i = 0; i < n; i++) { if (i < mid) ask(b[i]), lb.push_back(b[i]); else rb.push_back(b[i]); } for (int i : a) { if (la.size() == mid) ra.push_back(i); else if (ra.size() == n - mid) la.push_back(i); else if (f) { if (ask(i)) ra.push_back(i); else la.push_back(i); } else { if (ask(i)) la.push_back(i); else ra.push_back(i); } } solve(la, lb, f ^ 1); solve(ra, rb, f); } void Solve(int N) { vector<int> a, b; for (int i = 1; i <= 2 * N; i++) { if (ask(i)) a.push_back(i); else b.push_back(i); } solve(a, b, 0); }

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

minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:24:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     if (la.size() == mid) ra.push_back(i);
      |         ~~~~~~~~~~^~~~~~
minerals.cpp:25:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     else if (ra.size() == n - mid) la.push_back(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...