답안 #708291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708291 2023-03-11T13:58:21 Z 600Mihnea 이상한 기계 (APIO19_strange_device) C++17
0 / 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);
}

bool same_smart(int t1, int t2, int a, int b)
{
	a /= gcd(a, b + 1);
	a *= b;
	return t1 % a == t2 % a;
}

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);
		a *= b;
		mod = a;
	}
	set<int> s;
	vector<pair<int, int>> segs(n);
	for (auto& it : segs)
	{
		cin >> it.first >> it.second;
		int bag = 0;
		for (int j = it.first; j <= it.second; j++)
		{
			bag++;
			s.insert(j % mod);
		}
		if (bag >= mod)
		{
			assert((int)s.size() == mod);
		}
	}
	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();

	int cnt = 0;

	for (int a = 2; a <= lim; a++)
	{
		for (int b = 1; b <= lim; b++)
		{
			for (int t = 0; t <= 2 * a * b; t++)
			{
				for (int t2 = 0; t2 <= 2 * a * b; t2++)
				{
					bool s1 = same_dumb(t, t2, a, b);
					bool s2 = same_smart(t, t2, a, b);
					if (s1 != s2)
					{
						cout << "WA!\n";
						return 0;
					}
				}
			}
		
			cout << "done " << a << " " << b << "\n";
		}
	}

	cout << "Ac!\n";

	return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:114:6: warning: unused variable 'cnt' [-Wunused-variable]
  114 |  int cnt = 0;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 33 ms 9408 KB Output is correct
3 Correct 49 ms 13604 KB Output is correct
4 Correct 1 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 5 ms 980 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 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 1 ms 340 KB Output is correct
15 Correct 24 ms 5336 KB Output is correct
16 Correct 18 ms 5304 KB Output is correct
17 Correct 50 ms 6568 KB Output is correct
18 Runtime error 1 ms 468 KB Execution killed with signal 6
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 4061 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 86 ms 24392 KB Output is correct
3 Correct 78 ms 24080 KB Output is correct
4 Correct 78 ms 22940 KB Output is correct
5 Execution timed out 5088 ms 62620 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 498 ms 62852 KB Output is correct
3 Runtime error 2258 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 498 ms 62852 KB Output is correct
3 Runtime error 2258 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 498 ms 62852 KB Output is correct
3 Runtime error 2258 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 232 KB Output is correct
2 Runtime error 2315 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 33 ms 9408 KB Output is correct
3 Correct 49 ms 13604 KB Output is correct
4 Correct 1 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 5 ms 980 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 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 1 ms 340 KB Output is correct
15 Correct 24 ms 5336 KB Output is correct
16 Correct 18 ms 5304 KB Output is correct
17 Correct 50 ms 6568 KB Output is correct
18 Runtime error 1 ms 468 KB Execution killed with signal 6
19 Halted 0 ms 0 KB -