Submission #781732

# Submission time Handle Problem Language Result Execution time Memory
781732 2023-07-13T10:27:51 Z makanhulia Strange Device (APIO19_strange_device) C++17
0 / 100
13 ms 596 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fi first
#define se second
#define pb push_back
#define TC int t; cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
//*AC BERSAMA ALLAH  FORTIS FORTUNA ADIUVAT
//# nyampah

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n,a,b; 
    cin>>n>>a>>b;

    vector<bool> freq(1000005);
    for(int i=1;i<=n;i++){
        int l,r; cin>>l>>r;
        for(int j=l;j<=r;j++){
            int k=j%(a*b);
            if(k==0) k=a*b;
            freq[k]=1;
        }
    }

    set<pair<ll,ll> > sp;
    int cnt=0;
    for(int i=0;i<1000005;i++){
        int j=i;
        if(i==0) j=a*b;
        if(freq[j]) {
            if(sp.count(make_pair((j+j/b)%a,j%b))) continue;
            sp.insert(make_pair((j+j/b)%a,j%b));
            cnt++;
        }
    }
    cout<<cnt<<'\n';


    return 0;
}

// ll gcd(ll a, ll b){
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Runtime error 2 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 436 KB Output is correct
2 Runtime error 1 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Incorrect 13 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Incorrect 13 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Incorrect 13 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 440 KB Output is correct
2 Runtime error 3 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Runtime error 2 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -