SHOW:
|
|
- or go back to the newest paste.
1 | /* | |
2 | * Author : pedrocas | |
3 | * Date : 2023 Sep 24 11:44:35 AM | |
4 | */ | |
5 | ||
6 | #include <bits/stdc++.h> | |
7 | ||
8 | using namespace std; | |
9 | ||
10 | typedef long long ll; | |
11 | const long long mod = 1000000007; | |
12 | ll gcd (ll a, ll b) {return b==0 ? a : gcd(b, a%b);} | |
13 | ||
14 | #define all(c) (c).begin(),(c).end() | |
15 | #define pb push_back | |
16 | #define mp make_pair | |
17 | #define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); | |
18 | ||
19 | const int di4[] = {-1, 0, 1, 0}; | |
20 | const int dj4[] = { 0, 1, 0, -1}; | |
21 | const int di8[] = {-1, 0, 1, 0, -1, 1,-1,1}; | |
22 | const int dj8[] = { 0, 1, 0, -1, -1, 1,1,-1}; | |
23 | ||
24 | const int maxn = 2e5 + 10; | |
25 | const ll INF = 1e18; | |
26 | ||
27 | int main() | |
28 | { | |
29 | #ifdef LOCAL | |
30 | freopen("input.txt", "rt", stdin); | |
31 | freopen("output.txt", "wt", stdout); | |
32 | #endif | |
33 | fastio | |
34 | int tc = 1; | |
35 | //cin >> tc; | |
36 | while(tc-- ){ | |
37 | int n, k;cin >> n >> k; | |
38 | vector<int> v[n]; | |
39 | map<int, int> pos[n]; | |
40 | for(int i = 0; i<n; i++){ | |
41 | for(int j = 0, x; j<k; j++){ | |
42 | cin >> x; | |
43 | v[i].pb(x); | |
44 | pos[i][x] = j; | |
45 | } | |
46 | } | |
47 | vector<int> b = v[0]; | |
48 | vector<int> c[n]; | |
49 | vector<int> mx(n + 1, 0); | |
50 | int cnt = 0, ans = 1; | |
51 | mx[1] = 1; | |
52 | for(int i = 0; i<k; i++){ | |
53 | int el = b[i]; | |
54 | bool ok = true; | |
55 | for(int j = 1; ok&&j<n; j++){ | |
56 | if(c[j].size() == 0){ | |
57 | c[j].pb(pos[j][el]); | |
58 | }else{ | |
59 | - | }else{//faltava a porra deste else |
59 | + | |
60 | ok = false; | |
61 | }else{ | |
62 | c[j].push_back(pos[j][el]); | |
63 | } | |
64 | } | |
65 | } | |
66 | if(ok){ | |
67 | ans = max(ans, ++cnt); | |
68 | mx[cnt]++; | |
69 | }else{ | |
70 | cnt = 0; | |
71 | for(int j = 1; j< n; j++){ | |
72 | c[j].clear(); | |
73 | } | |
74 | - | cout << 1 << " " << n <<endl; |
74 | + | |
75 | - | }else cout << ans << " " <<1<<endl; |
75 | + | |
76 | if(ans == 1){ | |
77 | cout << 1 << " " << mx[ans] <<endl; | |
78 | }else cout << ans << " " <<mx[ans]<<endl; | |
79 | } | |
80 | return 0; | |
81 | } | |
82 | ||
83 |