Submission #544459

#TimeUsernameProblemLanguageResultExecution timeMemory
544459ac2huLightning Rod (NOI18_lightningrod)C++14
100 / 100
1888 ms262144 KiB
#include <bits/stdc++.h> #ifdef DEBUG #include "../templates/debug.h" #else #define deb(x...) #endif using namespace std; void setIO(string name) { #ifdef DEBUG #else ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); #endif } signed main() { iostream::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int n;cin >> n; vector<pair<int,int>> a(n); for(auto &e : a){ cin >> e.first >> e.second; } auto fit = [&](pair<int,int> a,pair<int,int> b) -> bool{ // if b can't fit a return (abs(b.first - a.first) <= abs(b.second - a.second)); }; auto better = [&](pair<int,int> a, pair<int,int> b) -> bool{ if(a.first + a.second > b.first + b.second) return true; return false; }; vector<pair<int,int>> st; st.push_back(a[0]); for(int i = 1;i<n;i++){ while(st.size() > 0 && fit(a[i], st.back()) && better(a[i], st.back())){ st.pop_back(); } if(st.size() == 0 || !fit(a[i], st.back())){//(!fit(a[i], st.back()) && !better(st.back(), a[i]))){ st.push_back(a[i]); } deb(st); } // cout << fit(a[n - 1], st.back()) << " " << better(st.back(), a[n - 1]) << "\n"; cout << st.size() << "\n"; }

Compilation message (stderr)

lightningrod.cpp: In function 'void setIO(std::string)':
lightningrod.cpp:12:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lightningrod.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...