Submission #409677

# Submission time Handle Problem Language Result Execution time Memory
409677 2021-05-21T10:47:53 Z Batorgil952 Strange Device (APIO19_strange_device) C++14
0 / 100
5000 ms 524292 KB
#include<bits/stdc++.h>
#define mp make_pair

using namespace std;

map< pair< int, int >, int > M;

int main(){
	long long n, q, p, i, j, x, y, a, b, s, P;
	
	scanf("%lld",&n);
	scanf("%lld",&q);
	scanf("%lld",&p);
	
	s=0;
	P=0;
	for(i=1; i<=n; i++){
		scanf("%lld",&x);
		scanf("%lld",&y);
		if(P==0){
			if(y-x+1>=p*q) s=p*q;
			else{
				for(j=x; j<=y; j++){
					a=(j+j/p)%q;
					b=j%p;
					M[mp(a, b)]++;
					if(M[mp(a, b)]==1) s++;
				}
			}
			if(s==p*q) P++;
		}
	}
	
	cout<<s<<endl;
	
	return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%lld",&n);
      |  ~~~~~^~~~~~~~~~~
strange_device.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%lld",&q);
      |  ~~~~~^~~~~~~~~~~
strange_device.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%lld",&p);
      |  ~~~~~^~~~~~~~~~~
strange_device.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%lld",&x);
      |   ~~~~~^~~~~~~~~~~
strange_device.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%lld",&y);
      |   ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 67 ms 12620 KB Output is correct
3 Correct 99 ms 18232 KB Output is correct
4 Correct 3 ms 844 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 292 KB Output is correct
9 Correct 13 ms 1100 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 63 ms 7000 KB Output is correct
16 Correct 42 ms 6972 KB Output is correct
17 Correct 83 ms 10224 KB Output is correct
18 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Execution timed out 5051 ms 461208 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 202 ms 32240 KB Output is correct
3 Correct 246 ms 32064 KB Output is correct
4 Correct 180 ms 30532 KB Output is correct
5 Execution timed out 5037 ms 62464 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 759 ms 63164 KB Output is correct
3 Runtime error 3487 ms 524292 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 759 ms 63164 KB Output is correct
3 Runtime error 3487 ms 524292 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 759 ms 63164 KB Output is correct
3 Runtime error 3487 ms 524292 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 2437 ms 524292 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 67 ms 12620 KB Output is correct
3 Correct 99 ms 18232 KB Output is correct
4 Correct 3 ms 844 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 292 KB Output is correct
9 Correct 13 ms 1100 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 63 ms 7000 KB Output is correct
16 Correct 42 ms 6972 KB Output is correct
17 Correct 83 ms 10224 KB Output is correct
18 Incorrect 1 ms 204 KB Output isn't correct