Submission #1166757

#TimeUsernameProblemLanguageResultExecution timeMemory
1166757shidou26Lightning Rod (NOI18_lightningrod)C++17
44 / 100
1095 ms78188 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define sz(v) (int)v.size() #define all(v) v.begin(), v.end() #define filter(v) v.resize(unique(all(v)) - v.begin()) #define dbg(v) "[" #v " = " << (v) << "]" template<typename T> bool maximize(T &a, T b) { if(a < b) { a = b; return true; }else return false; } template<typename T> bool minimize(T &a, T b) { if(a > b) { a = b; return true; }else return false; } typedef long long ll; typedef long double ld; const int N = 1e7 + 3; int n; pair<int, int> rods[N]; bool mark[N]; namespace subtask_1 { bool valid() { for(int i = 1; i <= n; i++) if(rods[i].second != 1) return false; return true; } void solve() { cout << n << endl; } }; void process() { if(subtask_1::valid()) return void(subtask_1::solve()); sort(rods + 1, rods + 1 + n, [](pair<int, int> a, pair<int, int> b){ return (a.second == b.second ? a.first < b.first : a.second > b.second); }); for(int i = 1; i <= n; i++) { mark[i] = true; for(int j = 1; j < i; j++) if(mark[j] && abs(rods[i].first - rods[j].first) <= rods[j].second - rods[i].second) { mark[i] = false; break; } } int answer = 0; for(int i = 1; i <= n; i++) answer += mark[i]; cout << answer << endl; } void input() { cin >> n; for(int i = 1; i <= n; i++) { cin >> rods[i].first >> rods[i].second; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); #define task "DateALive" if(fopen(task".INP", "r")) { freopen(task".INP", "r", stdin); freopen(task".OUT", "w", stdout); } int testcase = 1; // cin >> testcase; for(int i = 1; i <= testcase; i++) { input(); process(); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:79:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |                 freopen(task".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:80:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |                 freopen(task".OUT", "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...