답안 #171141

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171141 2019-12-27T13:40:51 Z joulej 이상한 기계 (APIO19_strange_device) C++17
10 / 100
5000 ms 524292 KB
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

ll GCD(ll x, ll y) {
	return (x == 0 ? y : GCD(y % x, x));
}

ll calc_period(ll A, ll B) {
	ll k = (A / GCD(A, B + 1));

	return k * B;
}

void solve() {
	int n = fetch<int>();
	ll A = fetch<ll>();
	ll B = fetch<ll>();
	set<ll> setik;
	ll p = calc_period(A, B);
	DBG(p);

	for(int i = 0; i < n; ++i) {
		ll L = fetch<ll>();
		ll R = fetch<ll>();

		for(ll x = L; x <= R; ++x) {
			setik.insert(x % p);
		}
	}

	cout << len(setik) << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 552 KB Output is correct
2 Correct 51 ms 9720 KB Output is correct
3 Correct 82 ms 13944 KB Output is correct
4 Correct 4 ms 760 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 476 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 8 ms 1016 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 10 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 39 ms 5340 KB Output is correct
16 Correct 28 ms 5624 KB Output is correct
17 Correct 80 ms 8824 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 376 KB Output is correct
2 Execution timed out 5043 ms 449192 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 119 ms 24356 KB Output is correct
3 Correct 116 ms 24064 KB Output is correct
4 Correct 113 ms 23032 KB Output is correct
5 Execution timed out 5073 ms 47068 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 795 ms 84648 KB Output is correct
3 Runtime error 3096 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 795 ms 84648 KB Output is correct
3 Runtime error 3096 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 795 ms 84648 KB Output is correct
3 Runtime error 3096 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Runtime error 3030 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 552 KB Output is correct
2 Correct 51 ms 9720 KB Output is correct
3 Correct 82 ms 13944 KB Output is correct
4 Correct 4 ms 760 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 476 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 8 ms 1016 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 10 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 39 ms 5340 KB Output is correct
16 Correct 28 ms 5624 KB Output is correct
17 Correct 80 ms 8824 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 10 ms 376 KB Output is correct
20 Execution timed out 5043 ms 449192 KB Time limit exceeded
21 Halted 0 ms 0 KB -