# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
970314 |
2024-04-26T10:53:38 Z |
parlimoos |
Naan (JOI19_naan) |
C++17 |
|
850 ms |
134120 KB |
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define arr(x) array<ll , x>
#define endl '\n'
ll n , l;
ll mat[3000][3000];
vector<arr(2)> pts[3000] , o;
vector<int> ord;
bool use[3000];
bool cmpKsr(arr(2) a , arr(2) b){
ll g = __gcd(a[0] , b[0]);
a[0] /= g , b[0] /= g;
g = __gcd(a[1] , b[1]);
a[1] /= g , b[1] /= g;
return ((a[0] * b[1]) < (a[1] * b[0]));
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
// freopen("in.txt" , "r" , stdin);
cin >> n >> l;
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < l ; j++){
cin >> mat[i][j];
mat[i][j] *= n;
}
}
for(int i = 0 ; i < n ; i++){
ll sm = 0 , tn = 0;
for(int j = 0 ; j < l ; j++) sm += mat[i][j];
sm /= n , tn = sm;
for(ll j = 0 ; j < l ; j++){
while(mat[i][j] >= tn){
arr(2) d = {tn , mat[i][j]};
ll g = __gcd(d[0] , d[1]);
d[0] /= g , d[1] /= g;
d[0] += j * d[1];
pts[i].pb(d);
tn += sm;
}
tn -= mat[i][j];
}
}
for(int i = 0 ; i < n ; i++){
arr(2) pt = {-1 , -1};
int inx = -1;
for(int j = 0 ; j < n ; j++){
if(use[j]) continue;
if(pt[0] == -1 or cmpKsr(pts[j][i] , pt)){
pt = pts[j][i];
inx = j;
}
}
o.pb(pt) , use[inx] = 1 , ord.pb(inx);
}
// for(int i = 1 ; i < n - 1 ; i++){
// if(!cmpKsr(o[i - 1] , o[i])){
// cout << o[i][0] << " " << o[i][1] << ":\n";
// cout << o[i - 1][0] << " " << o[i - 1][1] << "::\n";
// exit(0);
// }
// }
for(int i = 1 ; i < n ; i++) cout << o[i - 1][0] << " " << o[i - 1][1] << endl;
for(int i = 0 ; i < n ; i++) cout << ord[i] + 1 << " ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
1 ms |
2648 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
1 ms |
2660 KB |
Output is correct |
19 |
Correct |
1 ms |
2652 KB |
Output is correct |
20 |
Correct |
1 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
2652 KB |
Output is correct |
22 |
Correct |
1 ms |
2652 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
2652 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
2652 KB |
Output is correct |
19 |
Correct |
1 ms |
2648 KB |
Output is correct |
20 |
Correct |
2 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2652 KB |
Output is correct |
25 |
Correct |
1 ms |
2652 KB |
Output is correct |
26 |
Correct |
1 ms |
2392 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
2644 KB |
Output is correct |
30 |
Correct |
1 ms |
2652 KB |
Output is correct |
31 |
Correct |
1 ms |
2648 KB |
Output is correct |
32 |
Correct |
1 ms |
2652 KB |
Output is correct |
33 |
Correct |
1 ms |
2660 KB |
Output is correct |
34 |
Correct |
1 ms |
2652 KB |
Output is correct |
35 |
Correct |
1 ms |
2652 KB |
Output is correct |
36 |
Correct |
1 ms |
2652 KB |
Output is correct |
37 |
Correct |
1 ms |
2652 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
1 ms |
2652 KB |
Output is correct |
40 |
Correct |
1 ms |
604 KB |
Output is correct |
41 |
Correct |
1 ms |
348 KB |
Output is correct |
42 |
Correct |
1 ms |
2652 KB |
Output is correct |
43 |
Correct |
78 ms |
22116 KB |
Output is correct |
44 |
Correct |
494 ms |
68712 KB |
Output is correct |
45 |
Correct |
162 ms |
34640 KB |
Output is correct |
46 |
Correct |
15 ms |
6048 KB |
Output is correct |
47 |
Correct |
269 ms |
48976 KB |
Output is correct |
48 |
Correct |
705 ms |
107944 KB |
Output is correct |
49 |
Correct |
157 ms |
35924 KB |
Output is correct |
50 |
Correct |
850 ms |
116592 KB |
Output is correct |
51 |
Correct |
278 ms |
50004 KB |
Output is correct |
52 |
Correct |
687 ms |
101540 KB |
Output is correct |
53 |
Correct |
638 ms |
97892 KB |
Output is correct |
54 |
Correct |
1 ms |
604 KB |
Output is correct |
55 |
Correct |
348 ms |
72452 KB |
Output is correct |
56 |
Correct |
384 ms |
67060 KB |
Output is correct |
57 |
Correct |
315 ms |
60268 KB |
Output is correct |
58 |
Correct |
572 ms |
97900 KB |
Output is correct |
59 |
Correct |
297 ms |
55664 KB |
Output is correct |
60 |
Correct |
534 ms |
133748 KB |
Output is correct |
61 |
Correct |
546 ms |
133724 KB |
Output is correct |
62 |
Correct |
765 ms |
133780 KB |
Output is correct |
63 |
Correct |
669 ms |
134120 KB |
Output is correct |
64 |
Correct |
596 ms |
134012 KB |
Output is correct |
65 |
Correct |
597 ms |
120656 KB |
Output is correct |
66 |
Correct |
594 ms |
120676 KB |
Output is correct |
67 |
Correct |
560 ms |
120696 KB |
Output is correct |
68 |
Correct |
220 ms |
74828 KB |
Output is correct |
69 |
Correct |
216 ms |
68180 KB |
Output is correct |
70 |
Correct |
275 ms |
88944 KB |
Output is correct |
71 |
Correct |
338 ms |
96588 KB |
Output is correct |