Submission #1044834

# Submission time Handle Problem Language Result Execution time Memory
1044834 2024-08-05T14:03:10 Z vjudge1 Strange Device (APIO19_strange_device) C++17
5 / 100
1778 ms 524288 KB
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff fir -st
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int32_t main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(a*b>1000000){
		set<pair<int,int>>st;
		for(int i=0;i<n;i++){
			int l,r;
			cin>>l>>r;
			for(int j=l;j<=r;j++){
				st.insert(make_pair((j+(j/b))%a,j%b));
			}
		}
		cout<<st.size()<<endl;
		return 0;
	}
	set<pair<int,int>>st;
	map<pair<int,int>,int>mp;
	for(int i=0;!st.count(make_pair((i+i/b)%a,i%b));i++){
		st.insert(make_pair((i+i/b)%a,i%b));
		mp[make_pair((i+i/b)%a,i%b)]=i;
	}
	vector<int>pre(st.size()+5);
	for(int i=0;i<n;i++){
		int l,r;
		cin>>l>>r;
		if(r-l+1>=st.size()){
			cout<<st.size()<<endl;
			return 0;
		}
		int x=mp[make_pair((l+l/b)%a,l%b)],y=mp[make_pair((r+r/b)%a,r%b)];
		if(x>y){
			pre[0]++;
			pre[y+1]--;
			pre[x]++;
			pre[st.size()]--;
		}
		else{
			pre[x]++;
			pre[y+1]--;
		}
	}
	int ans=0;
	for(int i=0;i<st.size();i++){
		pre[i]+=(i==0?0:pre[i-1]);
		ans+=(pre[i]!=0);
	}
	cout<<ans<<endl;
}

Compilation message

strange_device.cpp: In function 'int32_t main()':
strange_device.cpp:37:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::set<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   if(r-l+1>=st.size()){
      |      ~~~~~^~~~~~~~~~~
strange_device.cpp:54:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::set<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  for(int i=0;i<st.size();i++){
      |              ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 31 ms 12268 KB Output is correct
3 Correct 42 ms 18012 KB Output is correct
4 Correct 5 ms 2648 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 4 ms 2140 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 32 ms 16216 KB Output is correct
16 Correct 76 ms 25600 KB Output is correct
17 Correct 92 ms 8976 KB Output is correct
18 Runtime error 1778 ms 524288 KB Execution killed with signal 9
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1550 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 477 ms 128376 KB Output is correct
3 Correct 481 ms 130028 KB Output is correct
4 Correct 414 ms 108020 KB Output is correct
5 Correct 1008 ms 133232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 816 ms 62916 KB Output is correct
3 Runtime error 1117 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 816 ms 62916 KB Output is correct
3 Runtime error 1117 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 816 ms 62916 KB Output is correct
3 Runtime error 1117 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 894 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 31 ms 12268 KB Output is correct
3 Correct 42 ms 18012 KB Output is correct
4 Correct 5 ms 2648 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 4 ms 2140 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 32 ms 16216 KB Output is correct
16 Correct 76 ms 25600 KB Output is correct
17 Correct 92 ms 8976 KB Output is correct
18 Runtime error 1778 ms 524288 KB Execution killed with signal 9
19 Halted 0 ms 0 KB -