Submission #797462

#TimeUsernameProblemLanguageResultExecution timeMemory
797462beaconmcMinerals (JOI19_minerals)C++14
90 / 100
303 ms15460 KiB
#include "minerals.h" #include <bits/stdc++.h> typedef long long ll; #define FOR(i, x, y) for(ll i=x; i<y; i++) #define FORNEG(i, x, y) for(ll i=x; i>y; i--) #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL) std::set<ll> machine; int query(int a){ if (machine.count(a)){ machine.erase(a); }else{ machine.insert(a); } return Query(a); } void Solve(int N) { ll fuck = 0; using namespace std; vector<vector<ll>> top; vector<vector<ll>> bot; top.push_back({}); bot.push_back({}); ll cur = 0; FOR(i,1, 2*N+1){ ll result = query(i); if (result == cur + 1){ cur++; top[0].push_back(i); }else{ bot[0].push_back(i); } } ll sus = 0; while (!(top.size() == bot.size() && bot.size() == N)){ sus++; vector<vector<ll>> temp; for (auto&i : bot){ if (i.size() == 1){ temp.push_back(i); continue; } long double ratio = 2; if (i.size() >= 10) ratio = 2.51; vector<ll> temp2; ll cutoff = (long double) i.size() / ratio; FOR(j,0,cutoff){ temp2.push_back(i[j]); } temp.push_back(temp2); temp2.clear(); FOR(j, cutoff, i.size()){ temp2.push_back(i[j]); } temp.push_back(temp2); } bot = temp; temp.clear(); ll ind = 0; FOR(i,0,top.size()){ ll tempflag = -1; if (sus%2 == 0){ if (machine.count(bot[ind][0])) tempflag = (sus + 1)%2; else tempflag = sus%2; }else{ if (machine.count(bot[ind][0])) tempflag = sus%2; else tempflag = (sus+1)%2; } if (top[i].size() == 1){ ind += 1; temp.push_back(top[i]); continue; } if (top[i].size() == 2){ ll idkman = query(bot[ind][0]); ll newman = query(top[i][0]); bool cond = (idkman == newman); if (!(cond^tempflag)){ temp.push_back({top[i][1]}); temp.push_back({top[i][0]}); ind += 2; continue; }else{ temp.push_back({top[i][0]}); temp.push_back({top[i][1]}); ind += 2; continue; } } vector<ll> first; vector<ll> second; ll curval = 0; for (auto&j : bot[ind]){ curval = query(j); } for (auto&j : top[i]){ ll result = query(j); if (result != curval){ curval = result; first.push_back(j); }else{ second.push_back(j); } } if (tempflag%2==1){ temp.push_back(first); temp.push_back(second); } else{ temp.push_back(second); temp.push_back(first); } ind += 2; } top = temp; } FOR(i,0,N){ Answer((int) top[i][0],(int) bot[i][0]); } }

Compilation message (stderr)

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:49:51: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |   while (!(top.size() == bot.size() && bot.size() == N)){
      |                                        ~~~~~~~~~~~^~~~
minerals.cpp:8:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   74 |       FOR(j, cutoff, i.size()){
      |           ~~~~~~~~~~~~~~~~~~~      
minerals.cpp:74:7: note: in expansion of macro 'FOR'
   74 |       FOR(j, cutoff, i.size()){
      |       ^~~
minerals.cpp:8:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   90 |     FOR(i,0,top.size()){
      |         ~~~~~~~~~~~~~~             
minerals.cpp:90:5: note: in expansion of macro 'FOR'
   90 |     FOR(i,0,top.size()){
      |     ^~~
minerals.cpp:25:6: warning: unused variable 'fuck' [-Wunused-variable]
   25 |   ll fuck = 0;
      |      ^~~~
#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...