답안 #781615

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781615 2023-07-13T08:37:56 Z devariaota 이상한 기계 (APIO19_strange_device) C++17
10 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;

# define int long long
# define fir first
# define sec second
# define pb push_back

const int cnst = 2e5+5;
bool mutipletestcase = 0;
//bool debug = false;

int gcd(int a, int b) {return b ? gcd(b, a%b): a;}
int lcm(int a, int b) {return a/gcd(a, b)*b;}

void solve() {
    int n, a, b; cin >> n >> a >> b;

    // if(a*b <= 1e6) {
    //     int val = lcm(a, b);
    //     int ans = 0;
    //     int get[val*2+5];
    //     memset(get, 0, sizeof(get));

    //     while(n--) {
    //         int x, y; cin >> x >> y;
    //         int len = y-x+1;
    //         if(len > a*b) ans = val;
    //         x %= val;
    //         y %= val;
    //         if(y < x) y += val;
    //         // cerr << x << " " << y << endl;
    //         get[x]+=1, get[y+1] -= 1;
    //     }

    //     if(ans == val) cout << ans << endl;
    //     else {
    //         bool yes[val+5];
    //         memset(yes, 0, sizeof(yes));

    //         for(int i = 1; i<=2*val; i++) {
    //             get[i] += get[i-1];
    //             cerr << get[i] << " ";
    //             if(get[i]) yes[i%val] = 1;
    //         }
    //         for(int i = 0; i<val; i++) {
    //             if(yes[i]) ans++;
    //         }

    //         cout << ans << endl;
    //     }
    //     return;
    // }
    // if(b == 1) {

    // }

    set<pair<int, int>> st;
    while(n--) {
        int x, y; cin >> x >> y;
        for(int i = x; i<=y; i++) {
            st.insert({(i+i/b)%a, i%b});
        }
    }

    cout << st.size() << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    int t = 1;
    if(mutipletestcase) cin >> t; 
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 36 ms 12240 KB Output is correct
3 Correct 51 ms 17836 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 6 ms 1108 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 31 ms 6932 KB Output is correct
16 Correct 25 ms 7076 KB Output is correct
17 Correct 45 ms 8268 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 2489 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 110 ms 32224 KB Output is correct
3 Correct 151 ms 31948 KB Output is correct
4 Correct 94 ms 30548 KB Output is correct
5 Execution timed out 5061 ms 62452 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 388 ms 62820 KB Output is correct
3 Runtime error 1312 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 388 ms 62820 KB Output is correct
3 Runtime error 1312 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 388 ms 62820 KB Output is correct
3 Runtime error 1312 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1195 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 36 ms 12240 KB Output is correct
3 Correct 51 ms 17836 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 6 ms 1108 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 31 ms 6932 KB Output is correct
16 Correct 25 ms 7076 KB Output is correct
17 Correct 45 ms 8268 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Runtime error 2489 ms 524288 KB Execution killed with signal 9
21 Halted 0 ms 0 KB -