Submission #994727

# Submission time Handle Problem Language Result Execution time Memory
994727 2024-06-08T04:33:16 Z PenguinsAreCute Portal (BOI24_portal) C++17
50 / 100
83 ms 6600 KB
// yay linear algebra!
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int SQDET = 2828432;
bool pr[SQDET];
vector<int> primes;
int test(int x[], int y[], int n, int p) {
	// test against the guy with gcd with lowest vp.
	pair<int,int> l = {100,0};
	for(int i=1;i<n;i++) {
		int g = __gcd(x[i],y[i]), c = 0;
		while((!(g%p)) && c<100) g/=p, c++;
		l=min(l,{c,i});
	}
	int g = 0;
	for(int i=1;i<n;i++) g=__gcd(g,x[i]*y[l.second]-x[l.second]*y[i]);
	int c = 0; while(!(g%p)) g/=p,c++;
	return c;
}
main() {
	fill(pr,pr+SQDET,1);
	for(int i=2;i<SQDET;i++) if(pr[i]) {
		primes.push_back(i);
		for(int j=i*i;j<SQDET;j+=i) pr[j]=0;
	}
	int n; cin >> n;
	int x[n], y[n]; for(int i=0;i<n;i++) cin>>x[i]>>y[i];
	for(int i=1;i<n;i++) x[i]-=x[0],y[i]-=y[0];
	int g=0; for(int i=2;i<n;i++) g=__gcd(g,x[1]*y[i]-x[i]*y[1]);
	if(!g) {cout<<-1; return 0;}
	int ans = 1;
	for(auto i: primes) if(!(g%i)) {
		int k = test(x,y,n,i);
		while(k--) ans *= i;
		while(!(g%i)) g/=i;
	}
	if(g>1 && test(x,y,n,g)) ans *= g;
	cout << ans;
}

Compilation message

Main.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5328 KB Output is correct
2 Correct 10 ms 5328 KB Output is correct
3 Correct 9 ms 5328 KB Output is correct
4 Correct 9 ms 5328 KB Output is correct
5 Correct 9 ms 5328 KB Output is correct
6 Correct 10 ms 5360 KB Output is correct
7 Correct 10 ms 5356 KB Output is correct
8 Correct 9 ms 5328 KB Output is correct
9 Correct 9 ms 5328 KB Output is correct
10 Correct 10 ms 5364 KB Output is correct
11 Correct 10 ms 5328 KB Output is correct
12 Correct 10 ms 5276 KB Output is correct
13 Correct 10 ms 5328 KB Output is correct
14 Correct 10 ms 5328 KB Output is correct
15 Correct 10 ms 5328 KB Output is correct
16 Correct 10 ms 5328 KB Output is correct
17 Correct 9 ms 5328 KB Output is correct
18 Correct 9 ms 5328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5328 KB Output is correct
2 Correct 10 ms 5328 KB Output is correct
3 Correct 9 ms 5328 KB Output is correct
4 Correct 9 ms 5328 KB Output is correct
5 Correct 9 ms 5328 KB Output is correct
6 Correct 10 ms 5360 KB Output is correct
7 Correct 10 ms 5356 KB Output is correct
8 Correct 9 ms 5328 KB Output is correct
9 Correct 9 ms 5328 KB Output is correct
10 Correct 10 ms 5364 KB Output is correct
11 Correct 10 ms 5328 KB Output is correct
12 Correct 10 ms 5276 KB Output is correct
13 Correct 10 ms 5328 KB Output is correct
14 Correct 10 ms 5328 KB Output is correct
15 Correct 10 ms 5328 KB Output is correct
16 Correct 10 ms 5328 KB Output is correct
17 Correct 9 ms 5328 KB Output is correct
18 Correct 9 ms 5328 KB Output is correct
19 Correct 10 ms 5388 KB Output is correct
20 Correct 11 ms 5324 KB Output is correct
21 Correct 11 ms 5364 KB Output is correct
22 Correct 10 ms 5324 KB Output is correct
23 Correct 10 ms 5324 KB Output is correct
24 Correct 10 ms 5328 KB Output is correct
25 Correct 10 ms 5328 KB Output is correct
26 Correct 10 ms 5328 KB Output is correct
27 Correct 9 ms 5288 KB Output is correct
28 Correct 11 ms 5324 KB Output is correct
29 Correct 11 ms 5364 KB Output is correct
30 Correct 10 ms 5328 KB Output is correct
31 Correct 10 ms 5328 KB Output is correct
32 Correct 10 ms 5364 KB Output is correct
33 Correct 10 ms 5364 KB Output is correct
34 Correct 10 ms 5360 KB Output is correct
35 Correct 10 ms 5356 KB Output is correct
36 Correct 10 ms 5328 KB Output is correct
37 Correct 10 ms 5328 KB Output is correct
38 Correct 10 ms 5284 KB Output is correct
39 Correct 10 ms 5328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5328 KB Output is correct
2 Correct 76 ms 6348 KB Output is correct
3 Correct 79 ms 6476 KB Output is correct
4 Correct 75 ms 6348 KB Output is correct
5 Correct 71 ms 6344 KB Output is correct
6 Correct 69 ms 6484 KB Output is correct
7 Correct 55 ms 6492 KB Output is correct
8 Correct 49 ms 6492 KB Output is correct
9 Correct 45 ms 6416 KB Output is correct
10 Correct 80 ms 6348 KB Output is correct
11 Correct 70 ms 6348 KB Output is correct
12 Correct 68 ms 6348 KB Output is correct
13 Correct 10 ms 5328 KB Output is correct
14 Correct 61 ms 6348 KB Output is correct
15 Correct 63 ms 6384 KB Output is correct
16 Correct 75 ms 6344 KB Output is correct
17 Correct 80 ms 6348 KB Output is correct
18 Correct 80 ms 6600 KB Output is correct
19 Correct 80 ms 6384 KB Output is correct
20 Correct 83 ms 6344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5328 KB Output is correct
2 Correct 10 ms 5324 KB Output is correct
3 Correct 13 ms 5328 KB Output is correct
4 Correct 10 ms 5364 KB Output is correct
5 Correct 10 ms 5368 KB Output is correct
6 Correct 10 ms 5324 KB Output is correct
7 Correct 10 ms 5396 KB Output is correct
8 Correct 10 ms 5364 KB Output is correct
9 Correct 10 ms 5328 KB Output is correct
10 Correct 10 ms 5328 KB Output is correct
11 Correct 10 ms 5376 KB Output is correct
12 Correct 10 ms 5212 KB Output is correct
13 Correct 11 ms 5324 KB Output is correct
14 Correct 10 ms 5328 KB Output is correct
15 Correct 10 ms 5328 KB Output is correct
16 Correct 10 ms 5324 KB Output is correct
17 Correct 11 ms 5184 KB Output is correct
18 Correct 11 ms 5328 KB Output is correct
19 Correct 11 ms 5328 KB Output is correct
20 Correct 11 ms 5328 KB Output is correct
21 Correct 10 ms 5368 KB Output is correct
22 Correct 16 ms 5324 KB Output is correct
23 Correct 10 ms 5328 KB Output is correct
24 Correct 10 ms 5364 KB Output is correct
25 Correct 11 ms 5328 KB Output is correct
26 Correct 12 ms 5328 KB Output is correct
27 Correct 11 ms 5328 KB Output is correct
28 Correct 10 ms 5328 KB Output is correct
29 Correct 10 ms 5328 KB Output is correct
30 Correct 10 ms 5356 KB Output is correct
31 Correct 12 ms 5328 KB Output is correct
32 Correct 10 ms 5364 KB Output is correct
33 Correct 10 ms 5364 KB Output is correct
34 Correct 10 ms 5324 KB Output is correct
35 Correct 11 ms 5328 KB Output is correct
36 Correct 11 ms 5328 KB Output is correct
37 Correct 10 ms 5328 KB Output is correct
38 Correct 10 ms 5288 KB Output is correct
39 Correct 11 ms 5328 KB Output is correct
40 Correct 11 ms 5328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5328 KB Output is correct
2 Correct 10 ms 5328 KB Output is correct
3 Correct 9 ms 5328 KB Output is correct
4 Correct 9 ms 5328 KB Output is correct
5 Correct 9 ms 5328 KB Output is correct
6 Correct 10 ms 5360 KB Output is correct
7 Correct 10 ms 5356 KB Output is correct
8 Correct 9 ms 5328 KB Output is correct
9 Correct 9 ms 5328 KB Output is correct
10 Correct 10 ms 5364 KB Output is correct
11 Correct 10 ms 5328 KB Output is correct
12 Correct 10 ms 5276 KB Output is correct
13 Correct 10 ms 5328 KB Output is correct
14 Correct 10 ms 5328 KB Output is correct
15 Correct 10 ms 5328 KB Output is correct
16 Correct 10 ms 5328 KB Output is correct
17 Correct 9 ms 5328 KB Output is correct
18 Correct 9 ms 5328 KB Output is correct
19 Correct 10 ms 5388 KB Output is correct
20 Correct 11 ms 5324 KB Output is correct
21 Correct 11 ms 5364 KB Output is correct
22 Correct 10 ms 5324 KB Output is correct
23 Correct 10 ms 5324 KB Output is correct
24 Correct 10 ms 5328 KB Output is correct
25 Correct 10 ms 5328 KB Output is correct
26 Correct 10 ms 5328 KB Output is correct
27 Correct 9 ms 5288 KB Output is correct
28 Correct 11 ms 5324 KB Output is correct
29 Correct 11 ms 5364 KB Output is correct
30 Correct 10 ms 5328 KB Output is correct
31 Correct 10 ms 5328 KB Output is correct
32 Correct 10 ms 5364 KB Output is correct
33 Correct 10 ms 5364 KB Output is correct
34 Correct 10 ms 5360 KB Output is correct
35 Correct 10 ms 5356 KB Output is correct
36 Correct 10 ms 5328 KB Output is correct
37 Correct 10 ms 5328 KB Output is correct
38 Correct 10 ms 5284 KB Output is correct
39 Correct 10 ms 5328 KB Output is correct
40 Correct 10 ms 5328 KB Output is correct
41 Correct 10 ms 5324 KB Output is correct
42 Correct 13 ms 5328 KB Output is correct
43 Correct 10 ms 5364 KB Output is correct
44 Correct 10 ms 5368 KB Output is correct
45 Correct 10 ms 5324 KB Output is correct
46 Correct 10 ms 5396 KB Output is correct
47 Correct 10 ms 5364 KB Output is correct
48 Correct 10 ms 5328 KB Output is correct
49 Correct 10 ms 5328 KB Output is correct
50 Correct 10 ms 5376 KB Output is correct
51 Correct 10 ms 5212 KB Output is correct
52 Correct 11 ms 5324 KB Output is correct
53 Correct 10 ms 5328 KB Output is correct
54 Correct 10 ms 5328 KB Output is correct
55 Correct 10 ms 5324 KB Output is correct
56 Correct 11 ms 5184 KB Output is correct
57 Correct 11 ms 5328 KB Output is correct
58 Correct 11 ms 5328 KB Output is correct
59 Correct 11 ms 5328 KB Output is correct
60 Correct 10 ms 5368 KB Output is correct
61 Correct 16 ms 5324 KB Output is correct
62 Correct 10 ms 5328 KB Output is correct
63 Correct 10 ms 5364 KB Output is correct
64 Correct 11 ms 5328 KB Output is correct
65 Correct 12 ms 5328 KB Output is correct
66 Correct 11 ms 5328 KB Output is correct
67 Correct 10 ms 5328 KB Output is correct
68 Correct 10 ms 5328 KB Output is correct
69 Correct 10 ms 5356 KB Output is correct
70 Correct 12 ms 5328 KB Output is correct
71 Correct 10 ms 5364 KB Output is correct
72 Correct 10 ms 5364 KB Output is correct
73 Correct 10 ms 5324 KB Output is correct
74 Correct 11 ms 5328 KB Output is correct
75 Correct 11 ms 5328 KB Output is correct
76 Correct 10 ms 5328 KB Output is correct
77 Correct 10 ms 5288 KB Output is correct
78 Correct 11 ms 5328 KB Output is correct
79 Correct 11 ms 5328 KB Output is correct
80 Correct 12 ms 5328 KB Output is correct
81 Correct 12 ms 5328 KB Output is correct
82 Correct 10 ms 5328 KB Output is correct
83 Correct 10 ms 5324 KB Output is correct
84 Correct 10 ms 5396 KB Output is correct
85 Correct 10 ms 5388 KB Output is correct
86 Correct 11 ms 5328 KB Output is correct
87 Correct 11 ms 5328 KB Output is correct
88 Correct 10 ms 5328 KB Output is correct
89 Correct 12 ms 5328 KB Output is correct
90 Correct 11 ms 5236 KB Output is correct
91 Correct 12 ms 5324 KB Output is correct
92 Correct 11 ms 5328 KB Output is correct
93 Correct 12 ms 5328 KB Output is correct
94 Correct 11 ms 5328 KB Output is correct
95 Correct 11 ms 5328 KB Output is correct
96 Correct 11 ms 5360 KB Output is correct
97 Correct 12 ms 5328 KB Output is correct
98 Correct 11 ms 5300 KB Output is correct
99 Correct 12 ms 5328 KB Output is correct
100 Correct 12 ms 5328 KB Output is correct
101 Correct 11 ms 5208 KB Output is correct
102 Correct 11 ms 5328 KB Output is correct
103 Correct 11 ms 5328 KB Output is correct
104 Correct 11 ms 5320 KB Output is correct
105 Correct 11 ms 5364 KB Output is correct
106 Correct 11 ms 5328 KB Output is correct
107 Correct 10 ms 6352 KB Output is correct
108 Correct 10 ms 5368 KB Output is correct
109 Correct 11 ms 5364 KB Output is correct
110 Correct 11 ms 5328 KB Output is correct
111 Incorrect 12 ms 5580 KB Output isn't correct
112 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5328 KB Output is correct
2 Correct 10 ms 5328 KB Output is correct
3 Correct 9 ms 5328 KB Output is correct
4 Correct 9 ms 5328 KB Output is correct
5 Correct 9 ms 5328 KB Output is correct
6 Correct 10 ms 5360 KB Output is correct
7 Correct 10 ms 5356 KB Output is correct
8 Correct 9 ms 5328 KB Output is correct
9 Correct 9 ms 5328 KB Output is correct
10 Correct 10 ms 5364 KB Output is correct
11 Correct 10 ms 5328 KB Output is correct
12 Correct 10 ms 5276 KB Output is correct
13 Correct 10 ms 5328 KB Output is correct
14 Correct 10 ms 5328 KB Output is correct
15 Correct 10 ms 5328 KB Output is correct
16 Correct 10 ms 5328 KB Output is correct
17 Correct 9 ms 5328 KB Output is correct
18 Correct 9 ms 5328 KB Output is correct
19 Correct 10 ms 5388 KB Output is correct
20 Correct 11 ms 5324 KB Output is correct
21 Correct 11 ms 5364 KB Output is correct
22 Correct 10 ms 5324 KB Output is correct
23 Correct 10 ms 5324 KB Output is correct
24 Correct 10 ms 5328 KB Output is correct
25 Correct 10 ms 5328 KB Output is correct
26 Correct 10 ms 5328 KB Output is correct
27 Correct 9 ms 5288 KB Output is correct
28 Correct 11 ms 5324 KB Output is correct
29 Correct 11 ms 5364 KB Output is correct
30 Correct 10 ms 5328 KB Output is correct
31 Correct 10 ms 5328 KB Output is correct
32 Correct 10 ms 5364 KB Output is correct
33 Correct 10 ms 5364 KB Output is correct
34 Correct 10 ms 5360 KB Output is correct
35 Correct 10 ms 5356 KB Output is correct
36 Correct 10 ms 5328 KB Output is correct
37 Correct 10 ms 5328 KB Output is correct
38 Correct 10 ms 5284 KB Output is correct
39 Correct 10 ms 5328 KB Output is correct
40 Correct 10 ms 5328 KB Output is correct
41 Correct 76 ms 6348 KB Output is correct
42 Correct 79 ms 6476 KB Output is correct
43 Correct 75 ms 6348 KB Output is correct
44 Correct 71 ms 6344 KB Output is correct
45 Correct 69 ms 6484 KB Output is correct
46 Correct 55 ms 6492 KB Output is correct
47 Correct 49 ms 6492 KB Output is correct
48 Correct 45 ms 6416 KB Output is correct
49 Correct 80 ms 6348 KB Output is correct
50 Correct 70 ms 6348 KB Output is correct
51 Correct 68 ms 6348 KB Output is correct
52 Correct 10 ms 5328 KB Output is correct
53 Correct 61 ms 6348 KB Output is correct
54 Correct 63 ms 6384 KB Output is correct
55 Correct 75 ms 6344 KB Output is correct
56 Correct 80 ms 6348 KB Output is correct
57 Correct 80 ms 6600 KB Output is correct
58 Correct 80 ms 6384 KB Output is correct
59 Correct 83 ms 6344 KB Output is correct
60 Correct 10 ms 5328 KB Output is correct
61 Correct 10 ms 5324 KB Output is correct
62 Correct 13 ms 5328 KB Output is correct
63 Correct 10 ms 5364 KB Output is correct
64 Correct 10 ms 5368 KB Output is correct
65 Correct 10 ms 5324 KB Output is correct
66 Correct 10 ms 5396 KB Output is correct
67 Correct 10 ms 5364 KB Output is correct
68 Correct 10 ms 5328 KB Output is correct
69 Correct 10 ms 5328 KB Output is correct
70 Correct 10 ms 5376 KB Output is correct
71 Correct 10 ms 5212 KB Output is correct
72 Correct 11 ms 5324 KB Output is correct
73 Correct 10 ms 5328 KB Output is correct
74 Correct 10 ms 5328 KB Output is correct
75 Correct 10 ms 5324 KB Output is correct
76 Correct 11 ms 5184 KB Output is correct
77 Correct 11 ms 5328 KB Output is correct
78 Correct 11 ms 5328 KB Output is correct
79 Correct 11 ms 5328 KB Output is correct
80 Correct 10 ms 5368 KB Output is correct
81 Correct 16 ms 5324 KB Output is correct
82 Correct 10 ms 5328 KB Output is correct
83 Correct 10 ms 5364 KB Output is correct
84 Correct 11 ms 5328 KB Output is correct
85 Correct 12 ms 5328 KB Output is correct
86 Correct 11 ms 5328 KB Output is correct
87 Correct 10 ms 5328 KB Output is correct
88 Correct 10 ms 5328 KB Output is correct
89 Correct 10 ms 5356 KB Output is correct
90 Correct 12 ms 5328 KB Output is correct
91 Correct 10 ms 5364 KB Output is correct
92 Correct 10 ms 5364 KB Output is correct
93 Correct 10 ms 5324 KB Output is correct
94 Correct 11 ms 5328 KB Output is correct
95 Correct 11 ms 5328 KB Output is correct
96 Correct 10 ms 5328 KB Output is correct
97 Correct 10 ms 5288 KB Output is correct
98 Correct 11 ms 5328 KB Output is correct
99 Correct 11 ms 5328 KB Output is correct
100 Correct 12 ms 5328 KB Output is correct
101 Correct 12 ms 5328 KB Output is correct
102 Correct 10 ms 5328 KB Output is correct
103 Correct 10 ms 5324 KB Output is correct
104 Correct 10 ms 5396 KB Output is correct
105 Correct 10 ms 5388 KB Output is correct
106 Correct 11 ms 5328 KB Output is correct
107 Correct 11 ms 5328 KB Output is correct
108 Correct 10 ms 5328 KB Output is correct
109 Correct 12 ms 5328 KB Output is correct
110 Correct 11 ms 5236 KB Output is correct
111 Correct 12 ms 5324 KB Output is correct
112 Correct 11 ms 5328 KB Output is correct
113 Correct 12 ms 5328 KB Output is correct
114 Correct 11 ms 5328 KB Output is correct
115 Correct 11 ms 5328 KB Output is correct
116 Correct 11 ms 5360 KB Output is correct
117 Correct 12 ms 5328 KB Output is correct
118 Correct 11 ms 5300 KB Output is correct
119 Correct 12 ms 5328 KB Output is correct
120 Correct 12 ms 5328 KB Output is correct
121 Correct 11 ms 5208 KB Output is correct
122 Correct 11 ms 5328 KB Output is correct
123 Correct 11 ms 5328 KB Output is correct
124 Correct 11 ms 5320 KB Output is correct
125 Correct 11 ms 5364 KB Output is correct
126 Correct 11 ms 5328 KB Output is correct
127 Correct 10 ms 6352 KB Output is correct
128 Correct 10 ms 5368 KB Output is correct
129 Correct 11 ms 5364 KB Output is correct
130 Correct 11 ms 5328 KB Output is correct
131 Incorrect 12 ms 5580 KB Output isn't correct
132 Halted 0 ms 0 KB -