Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std ;
- #define sz(s) int(s.size())
- #define all(s) s.begin() , s.end()
- #define getline(s) getline(cin >> ws, s)
- #define cin(v) for (auto& i : v) cin >> i ;
- #define cout(v) for (auto& i : v) cout << i << " "
- #define pb(x) push_back(x)
- #define ll long long
- #define ull unsigned long long
- #define Mod 1'000'000'007
- #define INF 2'000'000'000
- #define Num_of_Digits(n) ((int)log10(n)+1)
- #define fixed(n) fixed << setprecision(n)
- #define imin INT_MIN
- #define imax INT_MAX
- #define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs" << "\n" ;
- void ABDEL3AL () {
- ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
- #ifndef ONLINE_JUDGE
- freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
- #endif
- Time
- }
- int main() {
- ABDEL3AL() ;
- int n ; cin >> n ;
- int num = 0 ;
- vector < int > v(n) ; cin(v) ;
- vector < int > v1 , v2 , v3 ;
- set < int > st ;
- for (int i = 0; i < n; i++) {
- if (v[i] == 1) v1.push_back(i) ;
- else if (v[i] == 2) v2.push_back(i) ;
- else v3.push_back(i) ;
- }
- for (int i = 0; i < n; i++) {
- st.insert({v1[i] , v2[i] , v3[i]}) ;
- if (sz(st) % 3 == 0) num++ ;
- else break ;
- }
- if (num > 0) {
- cout << num << "\n" ;
- for (int i = 0; i < num; i++) cout << v1[i] << " " << v2[i] << " " << v3[i] << "\n" ;
- } else {
- cout << num ;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment