답안 #629510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
629510 2022-08-14T15:00:43 Z Cyber_Wolf 이상한 기계 (APIO19_strange_device) C++14
0 / 100
5000 ms 524288 KB
// Problem: P1 - Strange Device
// Contest: DMOJ - APIO '19
// URL: https://dmoj.ca/problem/apio19p1
// Memory Limit: 512 MB
// Time Limit: 1800 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>

using namespace std;

#define lg long long
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main()
{
	fastio;
	lg n, a, b;
	cin >> n >> a >> b;
	vector<pair<lg, lg>> v(n);
	set<pair<lg, lg>> se;
	lg ans = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> v[i].first >> v[i].second;
	} 
	for(auto [x, y] : v)
	{
		for(int j = x; j <= y; j++)
		{
			pair<lg, lg> p = {(j+j/b)%a, j%b};
			auto it = se.find(p);
			if(it == se.end())
			{
				se.insert(p);	
				ans++;
			}
		}
	}
	
	cout << ans << '\n';
	/*for(int i = 1; i <= 10; i++)
	{
		cout << (i+i/b)%a << ' ' << i%b << '\n';
	}*/
//	cout << min(a*b, v[0][1]-v[0][0]+1) << '\n';

    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:29:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |  for(auto [x, y] : v)
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5097 ms 405576 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 5033 ms 524288 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 5091 ms 60668 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5031 ms 117128 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5031 ms 117128 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5031 ms 117128 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 2041 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 Execution timed out 5097 ms 405576 KB Time limit exceeded
3 Halted 0 ms 0 KB -