Submission #232440

# Submission time Handle Problem Language Result Execution time Memory
232440 2020-05-17T04:23:18 Z limabeans Strange Device (APIO19_strange_device) C++17
0 / 100
5000 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll n, a, b;


ll getx(ll t) {
    return (t+t/b)%a;
}

ll gety(ll t) {
    return t%b;
}


vector<pair<ll,ll>> v;

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

    cin>>n>>a>>b;
    v.resize(n);
    for (int i=0; i<n; i++) {
	cin>>v[i].first>>v[i].second;

	v[i].first %= (a*b);
	v[i].second %= (a*b);
    }

    vector<ll> hit(a*b, 0);
    
    for (int i=0; i<n; i++) {
	ll l = v[i].first;
	ll r = v[i].second;

	if (r<l) r+= (a*b);

	for (ll x=l; x<=r; x++) {
	    hit[x%(a*b)]=1;
	}
    }



    ll res = accumulate(hit.begin(), hit.end(), 00);
    out(res);    


    // for (int t=1; t<=100; t++) {
    // 	ll x = getx(t);
    // 	ll y = gety(t);
    // 	cout<<t<<": "<<x<<" "<<y<<endl;
    // }
  

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 40 ms 51452 KB Output is correct
3 Correct 37 ms 39676 KB Output is correct
4 Incorrect 7 ms 4096 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Runtime error 257 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 14 ms 7936 KB Output is correct
3 Correct 15 ms 8192 KB Output is correct
4 Correct 12 ms 6784 KB Output is correct
5 Execution timed out 5054 ms 49016 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 455 ms 44440 KB Output is correct
3 Runtime error 455 ms 51576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 455 ms 44440 KB Output is correct
3 Runtime error 455 ms 51576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 455 ms 44440 KB Output is correct
3 Runtime error 455 ms 51576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Runtime error 298 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 40 ms 51452 KB Output is correct
3 Correct 37 ms 39676 KB Output is correct
4 Incorrect 7 ms 4096 KB Output isn't correct
5 Halted 0 ms 0 KB -