답안 #795474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
795474 2023-07-27T10:13:22 Z RecursiveCo 이상한 기계 (APIO19_strange_device) C++14
5 / 100
545 ms 68928 KB
// CF template, version 3.0

#include <bits/stdc++.h>

using namespace std;

#define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0)
#define getTest int t; cin >> t
#define eachTest for (int _var=0;_var<t;_var++)
#define get(name) int (name); cin >> (name)
#define out(o) cout << (o)
#define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
#define sortl(name) sort((name).begin(), (name).end())
#define rev(name) reverse((name).begin(), (name).end())
#define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
#define decision(b) if (b){out("YES");}else{out("NO");}

#define int long long int

signed main() {
    improvePerformance;
    //getTest;

    //eachTest {
        get(n);
        get(A);
        get(B);
        bool toobig = 2e18 / A <= B; // should be good enough, theoretically.
        vector<pair<int, int>> events;
        forto(n, i) {
            get(l);
            get(r);
            if (!toobig) {
                l %= A * B;
                r %= A * B;
            }
            events.push_back({l, 1});
            events.push_back({r, -1});
            if (r < l) {
                events.push_back({0, 1});
                events.push_back({A * B - 1, -1});
            }
        }
        sortl(events);
        int ptr = -1;
        int i = 0;
        int balance = 0;
        int m = events.size();
        int ans = 0;
        while (i <= m) {
            if (i == m || (i != 0 && events[i].first != events[i - 1].first && balance == 0)) {
                ans += events[i - 1].first - ptr + 1;
                ptr = events[i].first;
            }
            if (i == 0) ptr = events[i].first;
            if (i == m) break;
            balance += events[i].second;
            i++;
        }
        out(ans);
    //}
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
strange_device.cpp:25:9: note: in expansion of macro 'get'
   25 |         get(n);
      |         ^~~
strange_device.cpp:10:23: warning: unnecessary parentheses in declaration of 'A' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
strange_device.cpp:26:9: note: in expansion of macro 'get'
   26 |         get(A);
      |         ^~~
strange_device.cpp:10:23: warning: unnecessary parentheses in declaration of 'B' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
strange_device.cpp:27:9: note: in expansion of macro 'get'
   27 |         get(B);
      |         ^~~
strange_device.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
strange_device.cpp:30:9: note: in expansion of macro 'forto'
   30 |         forto(n, i) {
      |         ^~~~~
strange_device.cpp:10:23: warning: unnecessary parentheses in declaration of 'l' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
strange_device.cpp:31:13: note: in expansion of macro 'get'
   31 |             get(l);
      |             ^~~
strange_device.cpp:10:23: warning: unnecessary parentheses in declaration of 'r' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
strange_device.cpp:32:13: note: in expansion of macro 'get'
   32 |             get(r);
      |             ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 1280 KB Output is correct
3 Correct 5 ms 1304 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 292 ms 56908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 412 ms 68928 KB Output is correct
3 Incorrect 358 ms 68892 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 412 ms 68928 KB Output is correct
3 Incorrect 358 ms 68892 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 412 ms 68928 KB Output is correct
3 Incorrect 358 ms 68892 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 41 ms 7216 KB Output is correct
3 Correct 44 ms 7312 KB Output is correct
4 Correct 545 ms 68892 KB Output is correct
5 Correct 47 ms 7224 KB Output is correct
6 Correct 41 ms 7236 KB Output is correct
7 Correct 43 ms 7212 KB Output is correct
8 Correct 44 ms 7272 KB Output is correct
9 Correct 40 ms 7212 KB Output is correct
10 Correct 44 ms 7180 KB Output is correct
11 Correct 41 ms 7244 KB Output is correct
12 Correct 37 ms 7296 KB Output is correct
13 Correct 43 ms 7236 KB Output is correct
14 Correct 473 ms 68912 KB Output is correct
15 Incorrect 44 ms 7284 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 1280 KB Output is correct
3 Correct 5 ms 1304 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -