Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- int main()
- {
- ll m, s;
- cin >> m >> s;
- vector<vector<ll>> z1(m);
- for (int i = 0; i < m; i++)
- {
- for (int j = 0; j < s; j++)
- {
- ll a;
- cin >> a;
- z1.at(i).push_back(a);
- }
- }
- map<ll, ll> z2;
- ll r;
- bool crt;
- ll we;
- for (int i = 0; i < s; i++)
- {
- we = i;
- for (int j = 0; j < m; j++)
- {
- z2[z1.at(j).at(i)] += 1;
- }
- crt = true;
- for (auto x : z2)
- {
- if (x.second != 3)
- {
- crt = false;
- break;
- }
- }
- if (crt == true)
- {
- r = i + 1;
- break;
- }
- }
- if (crt == false)
- {
- r = we + 1;
- }
- cout << r << endl;
- z1.at(0).resize(r);
- sort(z1.at(0).begin(), z1.at(0).end());
- for (int i = 0; i < r; i++)
- {
- cout << z1.at(0).at(i) << " ";
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment