답안 #708299

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708299 2023-03-11T14:04:33 Z 600Mihnea 이상한 기계 (APIO19_strange_device) C++17
10 / 100
5000 ms 524288 KB
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <cassert>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include <numeric>
#include <cstdint>
#include <limits>
#include <numeric>
#include <iostream>


using namespace std;

#define int long long

pair<int, int> get(int t, int a, int b)
{
	int x = (t + t / b) % a;
	int y = t % b;
	return { x, y };
}

bool same_dumb(int t1, int t2, int a, int b)
{
	return get(t1, a, b) == get(t2, a, b);
}

int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

const int lim = 20;

void print(vector<int> v)
{
	cout << " ---> ";
	for (auto& x : v)
	{
		cout << x << " ";
	}
	cout << "\n";
}

void solve()
{ 
	int n, mod;
	cin >> n;
	{
		int a, b;
		cin >> a >> b;
		a /= gcd(a, b + 1);	
		if (a <= ((int)1e18 + 7) / b)
		{
			a *= b;
			mod = a;
		}
		else
		{
			mod = ((int)1e18 + 7);
		}
	}
	set<int> s;
	auto add = [&](int l, int r)
	{
		if (l > r) return;
	
		for (int j = l; j <= r; j++) s.insert(j);
	};
	vector<pair<int, int>> segs(n);
	for (auto& it : segs)
	{
		cin >> it.first >> it.second;
		if (it.second - it.first + 1 >= mod)
		{
			cout << mod << "\n";
			exit(0);
		}
		int l = it.first % mod, r = it.second % mod;
		if (l <= r)
		{
			add(l, r);
		}
		else
		{
			add(l, mod - 1);
			add(0, r);
		}
	}
	cout << (int)s.size() << "\n";
	exit(0);
}

signed main()
{
#ifdef ONPC	
	FILE* stream;
	freopen_s(&stream, "input.txt", "r", stdin);
#else
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif

	solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 36 ms 9428 KB Output is correct
3 Correct 49 ms 13628 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 980 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 22 ms 5336 KB Output is correct
16 Correct 17 ms 5204 KB Output is correct
17 Correct 48 ms 6564 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 3802 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 76 ms 24180 KB Output is correct
3 Correct 73 ms 24108 KB Output is correct
4 Correct 72 ms 22980 KB Output is correct
5 Execution timed out 5049 ms 62628 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 552 ms 62932 KB Output is correct
3 Runtime error 2104 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 552 ms 62932 KB Output is correct
3 Runtime error 2104 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 552 ms 62932 KB Output is correct
3 Runtime error 2104 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 2188 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 36 ms 9428 KB Output is correct
3 Correct 49 ms 13628 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 980 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 22 ms 5336 KB Output is correct
16 Correct 17 ms 5204 KB Output is correct
17 Correct 48 ms 6564 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Runtime error 3802 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -