#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using ld = long double;
//#define int ll
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using tii = tuple<int,int,int>;
const int nmax = 5e5 + 5;
namespace Equalise {
vector<pair<int*, int*>> edgeref;
vector<int> g[nmax];
int pointer[nmax], occ[nmax];
void add_edge(int *a, int *b) {
if(*a == *b) return;
g[*a].emplace_back(sz(edgeref));
g[*b].emplace_back(sz(edgeref));
edgeref.emplace_back(a, b);
}
void init(vector<int> V) {
vector<int> st;
for(auto x : V) {
st.emplace_back(x);
while(!st.empty()) {
int node = st.back();
st.pop_back();
if(pointer[node] == sz(g[node])) continue;
st.emplace_back(node);
int u = g[node][pointer[node]++];
if(occ[u] == 1) continue;
occ[u] = 1;
if(*edgeref[u].first != node) swap(*edgeref[u].first, *edgeref[u].second);
st.emplace_back(*edgeref[u].second);
}
}
for(auto x : V) pointer[x] = 0, g[x].clear();
for(int i = 0; i < sz(edgeref); i++) occ[i] = 0;
edgeref.clear();
}
}
vector<vector<int>> mat;
void divide(int l, int r) {
if(l == r) return;
int mid = (l + r) >> 1;
vector<int> a;
for(int t = mid, t1 = mid + 1; t >= l; t--, t1++) {
for(int i = 0; i < sz(mat); i++)
Equalise::add_edge(&mat[i][t], &mat[i][t1]), a.emplace_back(mat[i][t]), a.emplace_back(mat[i][t1]);
}
Equalise::init(a);
divide(l, mid);
divide(mid + 1, r);
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int n, s, t;
cin >> n >> s >> t;
mat.resize(n, vector<int>(s));
for(auto &v : mat) for(auto &x : v) cin >> x;
divide(0, s - 1);
for(auto &v : mat) { for(auto &x : v) cout << x << ' '; cout << '\n'; }
return 0;
}
/**
Töte es durch genaue Untersuchung\Töte es kann es nur noch schlimmer machen\Es lässt es irgendwie atmen
--
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
12124 KB |
Correct |
2 |
Correct |
5 ms |
12004 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
12120 KB |
Correct |
2 |
Incorrect |
5 ms |
12124 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
25796 KB |
Correct |
2 |
Correct |
61 ms |
25792 KB |
Correct |
3 |
Correct |
79 ms |
23900 KB |
Correct |
4 |
Correct |
39 ms |
23088 KB |
Correct |
5 |
Correct |
54 ms |
25768 KB |
Correct |
6 |
Correct |
68 ms |
26304 KB |
Correct |
7 |
Correct |
64 ms |
27076 KB |
Correct |
8 |
Correct |
55 ms |
26708 KB |
Correct |
9 |
Correct |
48 ms |
26564 KB |
Correct |
10 |
Correct |
50 ms |
27916 KB |
Correct |
11 |
Correct |
48 ms |
27804 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
25796 KB |
Correct |
2 |
Correct |
61 ms |
25792 KB |
Correct |
3 |
Correct |
79 ms |
23900 KB |
Correct |
4 |
Correct |
39 ms |
23088 KB |
Correct |
5 |
Correct |
54 ms |
25768 KB |
Correct |
6 |
Correct |
68 ms |
26304 KB |
Correct |
7 |
Correct |
64 ms |
27076 KB |
Correct |
8 |
Correct |
55 ms |
26708 KB |
Correct |
9 |
Correct |
48 ms |
26564 KB |
Correct |
10 |
Correct |
50 ms |
27916 KB |
Correct |
11 |
Correct |
48 ms |
27804 KB |
Correct |
12 |
Correct |
64 ms |
25792 KB |
Correct |
13 |
Correct |
55 ms |
25796 KB |
Correct |
14 |
Correct |
54 ms |
23804 KB |
Correct |
15 |
Correct |
37 ms |
23076 KB |
Correct |
16 |
Correct |
55 ms |
25768 KB |
Correct |
17 |
Correct |
79 ms |
26516 KB |
Correct |
18 |
Correct |
60 ms |
27008 KB |
Correct |
19 |
Correct |
52 ms |
26560 KB |
Correct |
20 |
Correct |
55 ms |
26564 KB |
Correct |
21 |
Correct |
42 ms |
27840 KB |
Correct |
22 |
Correct |
46 ms |
27844 KB |
Correct |
23 |
Incorrect |
60 ms |
26004 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
12120 KB |
Correct |
2 |
Incorrect |
5 ms |
12124 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
12124 KB |
Correct |
2 |
Correct |
8 ms |
12636 KB |
Correct |
3 |
Correct |
8 ms |
12376 KB |
Correct |
4 |
Correct |
7 ms |
12636 KB |
Correct |
5 |
Correct |
6 ms |
12636 KB |
Correct |
6 |
Correct |
8 ms |
12892 KB |
Correct |
7 |
Correct |
7 ms |
12636 KB |
Correct |
8 |
Correct |
8 ms |
12636 KB |
Correct |
9 |
Correct |
8 ms |
12572 KB |
Correct |
10 |
Correct |
7 ms |
12644 KB |
Correct |
11 |
Correct |
6 ms |
12636 KB |
Correct |
12 |
Correct |
7 ms |
12892 KB |
Correct |
13 |
Correct |
7 ms |
12980 KB |
Correct |
14 |
Correct |
7 ms |
12892 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
12124 KB |
Correct |
2 |
Correct |
8 ms |
12636 KB |
Correct |
3 |
Correct |
8 ms |
12376 KB |
Correct |
4 |
Correct |
7 ms |
12636 KB |
Correct |
5 |
Correct |
6 ms |
12636 KB |
Correct |
6 |
Correct |
8 ms |
12892 KB |
Correct |
7 |
Correct |
7 ms |
12636 KB |
Correct |
8 |
Correct |
8 ms |
12636 KB |
Correct |
9 |
Correct |
8 ms |
12572 KB |
Correct |
10 |
Correct |
7 ms |
12644 KB |
Correct |
11 |
Correct |
6 ms |
12636 KB |
Correct |
12 |
Correct |
7 ms |
12892 KB |
Correct |
13 |
Correct |
7 ms |
12980 KB |
Correct |
14 |
Correct |
7 ms |
12892 KB |
Correct |
15 |
Correct |
5 ms |
12120 KB |
Correct |
16 |
Correct |
7 ms |
12636 KB |
Correct |
17 |
Correct |
9 ms |
12380 KB |
Correct |
18 |
Correct |
7 ms |
12636 KB |
Correct |
19 |
Correct |
7 ms |
12636 KB |
Correct |
20 |
Correct |
7 ms |
12992 KB |
Correct |
21 |
Correct |
11 ms |
12636 KB |
Correct |
22 |
Correct |
7 ms |
12636 KB |
Correct |
23 |
Correct |
8 ms |
12636 KB |
Correct |
24 |
Correct |
8 ms |
12636 KB |
Correct |
25 |
Correct |
6 ms |
12636 KB |
Correct |
26 |
Correct |
11 ms |
12892 KB |
Correct |
27 |
Correct |
8 ms |
12888 KB |
Correct |
28 |
Correct |
9 ms |
12784 KB |
Correct |
29 |
Incorrect |
8 ms |
12636 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
12124 KB |
Correct |
2 |
Correct |
8 ms |
12636 KB |
Correct |
3 |
Correct |
8 ms |
12376 KB |
Correct |
4 |
Correct |
7 ms |
12636 KB |
Correct |
5 |
Correct |
6 ms |
12636 KB |
Correct |
6 |
Correct |
8 ms |
12892 KB |
Correct |
7 |
Correct |
7 ms |
12636 KB |
Correct |
8 |
Correct |
8 ms |
12636 KB |
Correct |
9 |
Correct |
8 ms |
12572 KB |
Correct |
10 |
Correct |
7 ms |
12644 KB |
Correct |
11 |
Correct |
6 ms |
12636 KB |
Correct |
12 |
Correct |
7 ms |
12892 KB |
Correct |
13 |
Correct |
7 ms |
12980 KB |
Correct |
14 |
Correct |
7 ms |
12892 KB |
Correct |
15 |
Correct |
5 ms |
12120 KB |
Correct |
16 |
Correct |
7 ms |
12636 KB |
Correct |
17 |
Correct |
9 ms |
12380 KB |
Correct |
18 |
Correct |
7 ms |
12636 KB |
Correct |
19 |
Correct |
7 ms |
12636 KB |
Correct |
20 |
Correct |
7 ms |
12992 KB |
Correct |
21 |
Correct |
11 ms |
12636 KB |
Correct |
22 |
Correct |
7 ms |
12636 KB |
Correct |
23 |
Correct |
8 ms |
12636 KB |
Correct |
24 |
Correct |
8 ms |
12636 KB |
Correct |
25 |
Correct |
6 ms |
12636 KB |
Correct |
26 |
Correct |
11 ms |
12892 KB |
Correct |
27 |
Correct |
8 ms |
12888 KB |
Correct |
28 |
Correct |
9 ms |
12784 KB |
Correct |
29 |
Incorrect |
8 ms |
12636 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
25796 KB |
Correct |
2 |
Correct |
61 ms |
25792 KB |
Correct |
3 |
Correct |
79 ms |
23900 KB |
Correct |
4 |
Correct |
39 ms |
23088 KB |
Correct |
5 |
Correct |
54 ms |
25768 KB |
Correct |
6 |
Correct |
68 ms |
26304 KB |
Correct |
7 |
Correct |
64 ms |
27076 KB |
Correct |
8 |
Correct |
55 ms |
26708 KB |
Correct |
9 |
Correct |
48 ms |
26564 KB |
Correct |
10 |
Correct |
50 ms |
27916 KB |
Correct |
11 |
Correct |
48 ms |
27804 KB |
Correct |
12 |
Correct |
5 ms |
12124 KB |
Correct |
13 |
Correct |
8 ms |
12636 KB |
Correct |
14 |
Correct |
8 ms |
12376 KB |
Correct |
15 |
Correct |
7 ms |
12636 KB |
Correct |
16 |
Correct |
6 ms |
12636 KB |
Correct |
17 |
Correct |
8 ms |
12892 KB |
Correct |
18 |
Correct |
7 ms |
12636 KB |
Correct |
19 |
Correct |
8 ms |
12636 KB |
Correct |
20 |
Correct |
8 ms |
12572 KB |
Correct |
21 |
Correct |
7 ms |
12644 KB |
Correct |
22 |
Correct |
6 ms |
12636 KB |
Correct |
23 |
Correct |
7 ms |
12892 KB |
Correct |
24 |
Correct |
7 ms |
12980 KB |
Correct |
25 |
Correct |
7 ms |
12892 KB |
Correct |
26 |
Correct |
66 ms |
25696 KB |
Correct |
27 |
Correct |
89 ms |
25796 KB |
Correct |
28 |
Correct |
53 ms |
24016 KB |
Correct |
29 |
Correct |
36 ms |
23088 KB |
Correct |
30 |
Correct |
56 ms |
25768 KB |
Correct |
31 |
Correct |
61 ms |
26368 KB |
Correct |
32 |
Correct |
58 ms |
27076 KB |
Correct |
33 |
Correct |
69 ms |
26564 KB |
Correct |
34 |
Correct |
57 ms |
26564 KB |
Correct |
35 |
Correct |
42 ms |
28044 KB |
Correct |
36 |
Correct |
47 ms |
28188 KB |
Correct |
37 |
Correct |
6 ms |
12124 KB |
Correct |
38 |
Correct |
7 ms |
12636 KB |
Correct |
39 |
Correct |
8 ms |
12380 KB |
Correct |
40 |
Correct |
7 ms |
12632 KB |
Correct |
41 |
Correct |
6 ms |
12636 KB |
Correct |
42 |
Correct |
7 ms |
12892 KB |
Correct |
43 |
Correct |
6 ms |
12636 KB |
Correct |
44 |
Correct |
8 ms |
12636 KB |
Correct |
45 |
Correct |
8 ms |
12632 KB |
Correct |
46 |
Correct |
8 ms |
12636 KB |
Correct |
47 |
Correct |
7 ms |
12636 KB |
Correct |
48 |
Correct |
8 ms |
12892 KB |
Correct |
49 |
Correct |
8 ms |
12888 KB |
Correct |
50 |
Correct |
7 ms |
12888 KB |
Correct |
51 |
Correct |
207 ms |
33508 KB |
Correct |
52 |
Correct |
232 ms |
29068 KB |
Correct |
53 |
Correct |
43 ms |
14912 KB |
Correct |
54 |
Correct |
67 ms |
18108 KB |
Correct |
55 |
Correct |
190 ms |
25976 KB |
Correct |
56 |
Correct |
186 ms |
32884 KB |
Correct |
57 |
Correct |
212 ms |
33924 KB |
Correct |
58 |
Correct |
187 ms |
25428 KB |
Correct |
59 |
Correct |
149 ms |
22064 KB |
Correct |
60 |
Correct |
174 ms |
31956 KB |
Correct |
61 |
Correct |
195 ms |
33340 KB |
Correct |
62 |
Correct |
75 ms |
30692 KB |
Correct |
63 |
Correct |
71 ms |
30668 KB |
Correct |
64 |
Correct |
79 ms |
30920 KB |
Correct |
65 |
Correct |
71 ms |
30604 KB |
Correct |
66 |
Correct |
89 ms |
30848 KB |
Correct |
67 |
Correct |
75 ms |
30596 KB |
Correct |
68 |
Correct |
75 ms |
30896 KB |
Correct |
69 |
Correct |
75 ms |
30656 KB |
Correct |
70 |
Correct |
110 ms |
29548 KB |
Correct |
71 |
Correct |
85 ms |
30076 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
25796 KB |
Correct |
2 |
Correct |
61 ms |
25792 KB |
Correct |
3 |
Correct |
79 ms |
23900 KB |
Correct |
4 |
Correct |
39 ms |
23088 KB |
Correct |
5 |
Correct |
54 ms |
25768 KB |
Correct |
6 |
Correct |
68 ms |
26304 KB |
Correct |
7 |
Correct |
64 ms |
27076 KB |
Correct |
8 |
Correct |
55 ms |
26708 KB |
Correct |
9 |
Correct |
48 ms |
26564 KB |
Correct |
10 |
Correct |
50 ms |
27916 KB |
Correct |
11 |
Correct |
48 ms |
27804 KB |
Correct |
12 |
Correct |
64 ms |
25792 KB |
Correct |
13 |
Correct |
55 ms |
25796 KB |
Correct |
14 |
Correct |
54 ms |
23804 KB |
Correct |
15 |
Correct |
37 ms |
23076 KB |
Correct |
16 |
Correct |
55 ms |
25768 KB |
Correct |
17 |
Correct |
79 ms |
26516 KB |
Correct |
18 |
Correct |
60 ms |
27008 KB |
Correct |
19 |
Correct |
52 ms |
26560 KB |
Correct |
20 |
Correct |
55 ms |
26564 KB |
Correct |
21 |
Correct |
42 ms |
27840 KB |
Correct |
22 |
Correct |
46 ms |
27844 KB |
Correct |
23 |
Incorrect |
60 ms |
26004 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
12124 KB |
Correct |
2 |
Correct |
5 ms |
12004 KB |
Correct |
3 |
Correct |
6 ms |
12120 KB |
Correct |
4 |
Incorrect |
5 ms |
12124 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
5 |
Halted |
0 ms |
0 KB |
- |