Submission #1067578

#TimeUsernameProblemLanguageResultExecution timeMemory
1067578UnforgettableplPark (JOI17_park)C++17
10 / 100
45 ms604 KiB
#include "park.h" #include <bits/stdc++.h> using namespace std; static int Place[1400]; void strat1(int N) { for(int i=0;i<N;i++) { for(int j=i+1;j<N;j++) { Place[i]=Place[j]=1; if(Ask(i,j,Place))Answer(i,j); Place[i]=Place[j]=0; } } } void stratTree(int N) { vector<bool> used(N); vector<vector<int>> adj(N); used[0]=true; for(int y=1;y<N;y++) { if(used[y])continue; stack<int> s; s.emplace(y); vector<int> arm; while(!s.empty()) { int curr = s.top();s.pop(); used[curr]=true; function check = [&](int x) { for(int i=0;i<x;i++)Place[i]=true; for(int i=0;i<N;i++)if(used[i])Place[i]=true; bool ans = Ask(0,curr,Place); for(int i=0;i<N;i++)Place[i]=false; return !ans; }; int ans = -1; for(int jump=1024;jump;jump/=2) { if(ans+jump>=N)continue; if(check(ans+jump))ans+=jump; } if(ans==-1)arm.emplace_back(curr); else { s.emplace(curr); s.emplace(ans); } } for(int i=1;i<arm.size();i++) { adj[arm[i]].emplace_back(arm[i-1]); adj[arm[i-1]].emplace_back(arm[i]); Answer(arm[i],arm[i-1]); } vector<int> order; function<void(int,int)> dfs = [&](int x,int p) { order.emplace_back(x); for(int&i:adj[x])if(i!=p)dfs(i,x); }; dfs(0,-1); function check = [&](int x) { for(int i=0;i<x;i++)Place[order[i]]=true; Place[arm[0]]=true; bool ans = Ask(0,arm[0],Place); for(int i=0;i<N;i++)Place[i]=false; return !ans; }; int ans = 0; for(int jump=1024;jump;jump/=2) { if(ans+jump>=order.size())continue; if(check(ans+jump))ans+=jump; } adj[order[ans]].emplace_back(arm[0]); adj[arm[0]].emplace_back(order[ans]); Answer(arm[0],order[ans]); } } void Detect(int T, int N) { if(T==1)strat1(N); else stratTree(N); }

Compilation message (stderr)

park.cpp: In function 'void stratTree(int)':
park.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(int i=1;i<arm.size();i++) {
      |                     ~^~~~~~~~~~~
park.cpp:67:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             if(ans+jump>=order.size())continue;
      |                ~~~~~~~~^~~~~~~~~~~~~~
#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...