답안 #983039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
983039 2024-05-15T07:16:22 Z vjudge1 이상한 기계 (APIO19_strange_device) C++17
15 / 100
5000 ms 524288 KB
#include<bits/stdc++.h>
#define sz size()
#define ll long long
using namespace std;

void out(__int128 a)
{
    string s;
    while(a)
        s += char(a % 10 + '0'),
             a /= 10;
    reverse(s.begin(), s.end());
    cout << s;
}

void solve()
{
    ll n, A, B, i, j, k;
    cin >> n >> A >> B;
    ll l[n + 1], r[n + 1];
    for(i = 1; i <= n; ++i)
        cin >> l[i] >> r[i];

    if(n == 1)
    {
        ll g = __gcd(A, B);
        __int128 x = A, y = B, z = g, x0 = (r[1] - l[1] + 1);
        x = x * y;
        if(x0 < x) x = x0;
        out(x);
        return;
    }

    map<pair<ll, ll>, bool> m;
    for(i = 1; i <= n; ++i)
        for(j = l[i]; j <= r[i]; ++j)
            m[{(j + j / B) % A, j % B}] = 1;
    cout << m.sz;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
}

Compilation message

strange_device.cpp: In function 'void solve()':
strange_device.cpp:27:32: warning: unused variable 'z' [-Wunused-variable]
   27 |         __int128 x = A, y = B, z = g, x0 = (r[1] - l[1] + 1);
      |                                ^
strange_device.cpp:18:23: warning: unused variable 'k' [-Wunused-variable]
   18 |     ll n, A, B, i, j, k;
      |                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 35 ms 12372 KB Output is correct
3 Correct 53 ms 18512 KB Output is correct
4 Correct 2 ms 856 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 6 ms 1220 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 32 ms 6996 KB Output is correct
16 Correct 23 ms 7760 KB Output is correct
17 Correct 44 ms 10576 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 112 ms 32404 KB Output is correct
3 Correct 152 ms 32084 KB Output is correct
4 Correct 97 ms 30560 KB Output is correct
5 Execution timed out 5057 ms 91456 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 369 ms 78564 KB Output is correct
3 Runtime error 1597 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 369 ms 78564 KB Output is correct
3 Runtime error 1597 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 369 ms 78564 KB Output is correct
3 Runtime error 1597 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1368 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 35 ms 12372 KB Output is correct
3 Correct 53 ms 18512 KB Output is correct
4 Correct 2 ms 856 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 6 ms 1220 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 32 ms 6996 KB Output is correct
16 Correct 23 ms 7760 KB Output is correct
17 Correct 44 ms 10576 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 112 ms 32404 KB Output is correct
26 Correct 152 ms 32084 KB Output is correct
27 Correct 97 ms 30560 KB Output is correct
28 Execution timed out 5057 ms 91456 KB Time limit exceeded
29 Halted 0 ms 0 KB -