제출 #378172

#제출 시각아이디문제언어결과실행 시간메모리
378172JerryLiu06이상한 기계 (APIO19_strange_device)C++11
0 / 100
577 ms33340 KiB
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long ll; typedef pair<ll, int> pli; #define f first #define s second int N; ll A, B, ans = 0; vector<pli> E; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> N >> A >> B; ll MOD = A * B; if (MOD <= 0 || MOD > 1000000000000000000L) MOD = 1000000000000000010L; for (int i = 0; i < N; i++) { ll X, Y; cin >> X >> Y; X %= MOD; Y %= MOD; if (X <= Y) { E.push_back({X, 1}); E.push_back({Y, -1}); } else { E.push_back({0, 1}); E.push_back({Y, -1}); E.push_back({X, 1}); E.push_back({MOD - 1, -1}); } } sort(begin(E), end(E)); int prev = 0; int cur = 0; ll PREV = 0; ll NOW = 0; for (int i = 0; i < E.size(); ) { NOW = E[i].f; while (i < E.size() && E[i].f == NOW) cur += E[i++].s; if (prev > 0) ans += NOW - PREV; prev = cur; PREV = NOW; } cout << ans + 1 << endl; }

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:26:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |      for (int i = 0; i < E.size(); ) {
      |                      ~~^~~~~~~~~~
strange_device.cpp:27:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |          NOW = E[i].f; while (i < E.size() && E[i].f == NOW) cur += E[i++].s;
      |                               ~~^~~~~~~~~~
strange_device.cpp:29:10: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   29 |          if (prev > 0) ans += NOW - PREV; prev = cur; PREV = NOW;
      |          ^~
strange_device.cpp:29:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   29 |          if (prev > 0) ans += NOW - PREV; prev = cur; PREV = NOW;
      |                                           ^~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...