답안 #249843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
249843 2020-07-16T04:29:58 Z Evirir 이상한 기계 (APIO19_strange_device) C++17
0 / 100
5000 ms 524292 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define mset(d,val) memset((d),val,sizeof(d))
#define forn(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define fore(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define MAXN 1000005

int n;
ll A,B;
ll l[MAXN],r[MAXN];
map<ll,set<ll>> tpairs;
ll cnt=0;

void S1()
{
	forn(it,0,n){
		ll L=l[it], R=r[it];
		fore(i,L,R){
			ll x=(i+(i/B))%A;
			ll y=i%B;
			if(tpairs[x].find(y)==tpairs[x].end()){
				tpairs[x].insert(y);
				cnt++;
			}
		}
	}
	
	cout<<cnt<<'\n';
}

void S2()
{
	cout<<min(r[0]-l[0]+1, A*B)<<'\n';
}

/*void S4()
{
	forn(i,0,n){
		ll d=r[i]-l[i];
	
		if(A%2==0){
			cout<<max((d/2)+1, A/2)<<'\n';
		}
		
		else{
			cout<<max((d/2)+1, A)<<'\n';
		}
	}
}

void S3()
{
	ll ans[A][B];
	ll prev[A][B],preh[A][B];
	forn(i,0,n){
		ll Lx=(l[i]+l[i]/B)%A;
		ll Ly=l[i]%B;
		ll Rx=(R[i]+R[i]/B)%A;
		ll Ry=R[i]%B;
		cout<<1<<'\n';
	}
	
}*/

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n>>A>>B;
	forn(i,0,n){
		cin>>l[i]>>r[i];
	}
	
	if(n==1) S2();
	//else if(A*B<=1000000) S3();
	//else if(B==1) S4();
	else S1();
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Execution timed out 5097 ms 304860 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Execution timed out 5096 ms 46712 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Execution timed out 5101 ms 196600 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Execution timed out 5101 ms 196600 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Execution timed out 5101 ms 196600 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Runtime error 2938 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 1 ms 384 KB Output is correct
2 Execution timed out 5097 ms 304860 KB Time limit exceeded
3 Halted 0 ms 0 KB -