제출 #1281401

#제출 시각아이디문제언어결과실행 시간메모리
1281401red_soulsFire (BOI24_fire)C++17
13 / 100
46 ms4572 KiB
#include <bits/stdc++.h> #define ll long long #define task "FIRE" using namespace std; const int N = 5e5 + 16; int n, m, s[N], e[N]; namespace sub6 { struct line { int l, r, id; bool operator < (const line &other) const { if (l == other.l) { return r > other.r; } return l < other.l; } }; int cnt, result; line a[N]; bool visited[N]; void solve() { for (int i = 1; i <= n; i++) { if (s[i] < e[i]) { a[++cnt] = {s[i], e[i] - 1, i}; } else { if (s[i] <= m - 1) { a[++cnt] = {s[i], m - 1, i}; } if (e[i] - 1 >= 0) { a[++cnt] = {0, e[i] - 1, i}; } } } sort(a + 1, a + 1 + cnt); int curP = 1, p = 0; while (p <= m - 1) { int r = -1, rId = -1; while (curP <= cnt && a[curP].l <= p) { if (a[curP].r > r) { r = a[curP].r; rId = curP; } curP++; } if (r < p) { cout << -1; return; } p = r + 1; visited[a[rId].id] = true; } for (int i = 1; i <= n; i++) { if (visited[i]) { result++; } } cout << result; } } int main() { ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> s[i] >> e[i]; } sub6 :: solve(); return 0; }

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

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