답안 #798638

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798638 2023-07-30T22:10:55 Z gg123_pe 이상한 기계 (APIO19_strange_device) C++14
15 / 100
937 ms 32324 KB
#include <bits/stdc++.h> 
using namespace std; 

typedef long long ll; 
#define f(i,a,b) for(int i = a; i < b; i++)
const int N = 1e6 + 5; 

int n; 
ll l[N], r[N]; 
ll A, B, S; 

void subtask_1(){
    set <pair<ll,ll>> s;

    f(i,1,n+1){
        for(ll j = l[i]; j <= r[i]; j++){
            ll a, b; 
            a = (j + j/B) % A; 
            b = j % B; 
            s.insert({a, b}); 
        }
    }
    cout << s.size() << "\n"; 
}
void subtask_2(){
    ll X = A / __gcd(A, B+1);  
    ll period = X * B;  
    cout << min(r[1] - l[1] + 1, period) << "\n"; 
}
int main(){
    cin >> n >> A >> B; 

    f(i,1,n+1){
        cin >> l[i] >> r[i]; 
        S += r[i] - l[i] + 1; 
    }

    if(S <= N){
        subtask_1(); 
        return 0; 
    }
    if(n == 1){
        subtask_2(); 
        return 0; 
    }
    return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 43 ms 12596 KB Output is correct
3 Correct 70 ms 18196 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 1 ms 340 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 0 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 36 ms 6964 KB Output is correct
16 Correct 28 ms 6972 KB Output is correct
17 Correct 113 ms 8280 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 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 114 ms 32324 KB Output is correct
3 Correct 159 ms 32028 KB Output is correct
4 Correct 106 ms 30624 KB Output is correct
5 Incorrect 684 ms 15856 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 937 ms 16036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 937 ms 16036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 937 ms 16036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 108 ms 1880 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 43 ms 12596 KB Output is correct
3 Correct 70 ms 18196 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 1 ms 340 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 0 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 36 ms 6964 KB Output is correct
16 Correct 28 ms 6972 KB Output is correct
17 Correct 113 ms 8280 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 114 ms 32324 KB Output is correct
26 Correct 159 ms 32028 KB Output is correct
27 Correct 106 ms 30624 KB Output is correct
28 Incorrect 684 ms 15856 KB Output isn't correct
29 Halted 0 ms 0 KB -