Submission #836911

#TimeUsernameProblemLanguageResultExecution timeMemory
836911OzyMinerals (JOI19_minerals)C++17
40 / 100
16 ms3828 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define repa(i,a,b) for(int i = (a); i >= (b); i--) #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define pll pair<lli,lli> #define MAX 1000000 struct x { vector<lli> izq; vector<lli> der; }; lli n,pas,a,cont; vector<pll> parejas; queue<x> rangos; lli vis[MAX+2]; void Solve(int N) { n = N; x ran; //inicializo las mitades izq y der pas = 0; rep(i,1,2*n) { a = Query(i); if (a > pas) ran.izq.push_back(i); else ran.der.push_back(i); pas = a; } rep(i,1,2*n) Query(i); //mientras exista que dividir, voy y a terminarme la cola y meterlo en mis resultados rangos.push(ran); while (!rangos.empty()) { ran = rangos.front(); rangos.pop(); //debug(ran.izq.size()); //for(auto act : ran.izq) debugsl(act); //cout << endl; //for(auto act : ran.der) debugsl(act); //cout << endl; if (ran.izq.size() == 1) { parejas.push_back({ran.izq[0], ran.der[0]}); continue; } if(ran.izq.size() == 2) { Query(ran.izq[0]); a = Query(ran.der[0]); if (a == 2) { parejas.push_back({ran.izq[0], ran.der[1]}); parejas.push_back({ran.izq[1], ran.der[0]}); } else { parejas.push_back({ran.izq[0], ran.der[0]}); parejas.push_back({ran.izq[1], ran.der[1]}); } Query(ran.izq[0]); Query(ran.der[0]); continue; } lli terc = (ran.izq.size())/3; if (ran.izq.size()%3 == 2) terc++; x r1,r2,r3; rep(i,0,terc-1) { a = Query(ran.izq[i]); r1.izq.push_back(ran.izq[i]); } pas = a; for(auto act : ran.der) { vis[act] = 0; a = Query(act); if(a == pas) { Query(act); r1.der.push_back(act); vis[act] = 1; } pas = a; } //correct0 //ahora me toca llenar los r2 y r3 rep(i,0,terc-1) Query(ran.izq[i]); cont = 1; for(auto act : ran.der) { if(vis[act] == 1) continue; if (cont > terc) r3.der.push_back(act); else { r2.der.push_back(act); Query(act); } cont++; } pas = r3.der.size(); //debugsl(terc); //debug(pas); rep(i,terc,ran.izq.size()-1) { a = Query(ran.izq[i]); if(a == pas) r3.izq.push_back(ran.izq[i]); else r2.izq.push_back(ran.izq[i]); Query(ran.izq[i]); } for(auto act : r3.der) Query(act); rangos.push(r1); rangos.push(r2); rangos.push(r3); } for (auto act : parejas) Answer(act.first,act.second); return; }

Compilation message (stderr)

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:4:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
      |                                       ^
minerals.cpp:111:5: note: in expansion of macro 'rep'
  111 |     rep(i,terc,ran.izq.size()-1) {
      |     ^~~
#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...