Submission #328421

#TimeUsernameProblemLanguageResultExecution timeMemory
328421egasLightning Rod (NOI18_lightningrod)C++14
11 / 100
2071 ms158672 KiB
#include <bits/stdc++.h> using namespace std; bool done[30]; int tt=0; int solve(vector<pair<int,int> > &v) { int res=INT_MAX; for(int i=0; i<v.size(); i++) { int cnt=0; vector<int> temp; for(int j=i; j<v.size(); j++) { if(!done[j] and abs(v[i].second-v[j].second)>=abs(v[i].first-v[j].first)) { done[j]=1; cnt++; temp.push_back(j); } } for(int j=i; j>=0; j--) { if(!done[j] and abs(v[i].second-v[j].second)>=abs(v[i].first-v[j].first)) { done[j]=1; temp.push_back(j); cnt++; } } if(cnt>0) { res=min(res,1+solve(v)); } for(int x:temp) { done[x]=0; } } if(res==INT_MAX)res=0; return res; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pair<int,int> > v; bool isSub1=true; for(int i = 0 ; i < n ; i++) { int x; cin >> x; int y; cin >> y; if(y!=1)isSub1=false; v.push_back({x,y}); } if(isSub1) { cout << n << '\n'; } else { cout << solve(v) << '\n'; } return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int solve(std::vector<std::pair<int, int> >&)':
lightningrod.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0; i<v.size(); i++) {
      |                  ~^~~~~~~~~
lightningrod.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for(int j=i; j<v.size(); j++) {
      |                      ~^~~~~~~~~
#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...