Submission #836326

#TimeUsernameProblemLanguageResultExecution timeMemory
836326LiudasMinerals (JOI19_minerals)C++17
85 / 100
47 ms3824 KiB
#include "minerals.h" #include "minerals.h" #include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <iostream> #include <bits/stdc++.h> using namespace std; int last = 0; void div(vector<int> start, vector<int> end, int par){ int N = start.size(); if(start.size() != end.size()) cout << start.size() << " " << end.size() << endl; vector<int> l, r, le, re, left; if(N == 1){ Answer(start[0], end[0]); return; } if(par == 1){ for(int i = 0; i < N/2; i ++){ last = Query(start[i]); l.push_back(start[i]); } for(int i = N/2; i < N; i ++){ r.push_back(start[i]); } for(int i = 0; i < N; i ++){ int t = Query(end[i]); if(t != last){ last = t; le.push_back(end[i]); if(le.size() == (N+1)/2){ for(int j = i + 1; j < N; j ++){ left.push_back(end[j]); } break; } } else{ re.push_back(end[i]); if(re.size() == (N+1)/2){ for(int j = i + 1; j < N; j ++){ left.push_back(end[j]); } break; } } } if(le.size() != (N+1)/2){ if(le.size() < (N+3)/4){ for(int i : le){ Query(i); } for(int i : left){ le.push_back(i); } div(le, l, 0); } else{ for(int i : left){ le.push_back(i); Query(i); } div(le, l, 1); } } else{ div(le, l, 1); } if(re.size() != (N+1)/2){ if(re.size() < (N + 3)/4){ for(int i : re){ Query(i); } for(int i : left){ re.push_back(i); } div(r, re, 1); } else{ for(int i : left){ re.push_back(i); Query(i); } div(r, re, 2); } } else{ div(r, re, 2); } } else if (par == 2){ for(int i = 0; i < N/2; i ++){ last = Query(start[i]); l.push_back(start[i]); } for(int i = N/2; i < N; i ++){ r.push_back(start[i]); } for(int i = 0; i < N; i ++){ int t = Query(end[i]); if(t != last){ last = t; le.push_back(end[i]); if(le.size() == (N+1)/2){ for(int j = i + 1; j < N; j ++){ left.push_back(end[j]); } break; } } else{ re.push_back(end[i]); if(re.size() == (N+1)/2){ for(int j = i + 1; j < N; j ++){ left.push_back(end[j]); } break; } } } if(le.size() != (N+1)/2){ if(le.size() < (N+3)/4){ for(int i : le){ Query(i); } for(int i : left){ le.push_back(i); } div(le, l, 1); } else{ for(int i : left){ le.push_back(i); Query(i); } div(l, le, 0); } } else{ div(l, le, 0); } if(re.size() != (N+1)/2){ if(re.size() < (N + 3)/4){ for(int i : re){ Query(i); } for(int i : left){ re.push_back(i); } div(r, re, 2); } else{ for(int i : left){ re.push_back(i); Query(i); } div(r, re, 1); } } else{ div(r, re, 1); } } if(par == 0){ for(int i = 0; i < N/2; i ++){ last = Query(start[i]); l.push_back(start[i]); } for(int i = N/2; i < N; i ++){ r.push_back(start[i]); } for(int i = 0; i < N; i ++){ int t = Query(end[i]); if(t == last){ last = t; le.push_back(end[i]); if(le.size() == (N+1)/2){ for(int j = i + 1; j < N; j ++){ left.push_back(end[j]); } break; } } else{ last = t; re.push_back(end[i]); if(re.size() == (N+1)/2){ for(int j = i + 1; j < N; j ++){ left.push_back(end[j]); } break; } } } if(le.size() != (N+1)/2){ if(le.size() < (N+3)/4){ for(int i : le){ Query(i); } for(int i : left){ le.push_back(i); } div(l, le, 1); } else{ for(int i : left){ le.push_back(i); Query(i); } div(l, le, 2); } } else{ div(l, le, 2); } if(re.size() != (N+1)/2){ if(re.size() < (N + 3)/4){ for(int i : re){ Query(i); } for(int i : left){ re.push_back(i); } div(r, re, 0); } else{ for(int i : left){ re.push_back(i); Query(i); } div(re, r, 1); } } else{ div(re, r, 1); } } } void Solve(int N) { vector<int> start, end; vector<int> order(2 * N); iota(order.begin(), order.end(), 0); shuffle(order.begin(), order.end(), mt19937(225)); for(int i : order){ int t = start.size(); if(i < 0 || i >= N * 2){ cout << i << " ..." << endl; } int ans = Query(i+1); if(ans == t + 1){ start.push_back(i+1); } else{ end.push_back(i+1); } } last = N; div(start, end, 2); }

Compilation message (stderr)

minerals.cpp: In function 'void div(std::vector<int>, std::vector<int>, int)':
minerals.cpp:33:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |         if(le.size() == (N+1)/2){
      |            ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:42:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |         if(re.size() == (N+1)/2){
      |            ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:50:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |     if(le.size() != (N+1)/2){
      |        ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:51:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |       if(le.size() < (N+3)/4){
      |          ~~~~~~~~~~^~~~~~~~~
minerals.cpp:71:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |     if(re.size() != (N+1)/2){
      |        ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:72:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   72 |       if(re.size() < (N + 3)/4){
      |          ~~~~~~~~~~^~~~~~~~~~~
minerals.cpp:106:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  106 |         if(le.size() == (N+1)/2){
      |            ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:115:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  115 |         if(re.size() == (N+1)/2){
      |            ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:123:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  123 |     if(le.size() != (N+1)/2){
      |        ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:124:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  124 |       if(le.size() < (N+3)/4){
      |          ~~~~~~~~~~^~~~~~~~~
minerals.cpp:144:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  144 |     if(re.size() != (N+1)/2){
      |        ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:145:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  145 |       if(re.size() < (N + 3)/4){
      |          ~~~~~~~~~~^~~~~~~~~~~
minerals.cpp:179:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  179 |         if(le.size() == (N+1)/2){
      |            ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:189:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  189 |         if(re.size() == (N+1)/2){
      |            ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:197:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  197 |     if(le.size() != (N+1)/2){
      |        ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:198:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  198 |       if(le.size() < (N+3)/4){
      |          ~~~~~~~~~~^~~~~~~~~
minerals.cpp:218:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  218 |     if(re.size() != (N+1)/2){
      |        ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:219:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  219 |       if(re.size() < (N + 3)/4){
      |          ~~~~~~~~~~^~~~~~~~~~~
#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...