제출 #1166758

#제출 시각아이디문제언어결과실행 시간메모리
1166758shidou26Lightning Rod (NOI18_lightningrod)C++17
44 / 100
1096 ms78424 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; inline int readInt() { int x = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9'){ x = (x << 3) + (x << 1) + ch - '0'; ch = getchar(); } return x; } 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() { n = readInt(); for(int i = 1; i <= n; i++) { rods[i].first = readInt(); rods[i].second = readInt(); } } 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; }

컴파일 시 표준 에러 (stderr) 메시지

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