#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template < class S, class T> inline S min_L( S a,T b) {
return a<= b? a: b;
}
#define main dummy_main
int main( ) {
return 0 ;
}
#undef main
class Solution{
public :
vector< int > arraysIntersection( vector< int > & A, vector< int > & B, vector< int > & C) {
int a = 0 ;
int b = 0 ;
int c = 0 ;
int m;
vector< int > res;
while ( a < A.size ( ) && b < B.size ( ) && c < C.size ( ) ) {
if ( A[ a] == B[ b] && B[ b] == C[ c] ) {
res.push_back ( A[ a] ) ;
a++ ;
b++ ;
c++ ;
}
else {
m = min_L( min_L( A[ a] , B[ b] ) , C[ c] ) ;
if ( m== A[ a] ) {
a++ ;
}
if ( m== B[ b] ) {
b++ ;
}
if ( m== C[ c] ) {
c++ ;
}
}
}
return res;
}
}
;
// cLay varsion 20191006-1
// --- original code ---
// #define main dummy_main
// {}
// #undef main
//
// class Solution {
// public:
// vector<int> arraysIntersection(vector<int>& A, vector<int>& B, vector<int>& C) {
// int a = 0, b = 0, c = 0, m;
// vector<int> res;
// while(a < A.size() && b < B.size() && c < C.size()){
// if(A[a] == B[b] == C[c]){
// res.push_back(A[a]);
// a++; b++; c++;
// } else {
// m = min(A[a], B[b], C[c]);
// if(m==A[a]) a++;
// if(m==B[b]) b++;
// if(m==C[c]) c++;
// }
// }
// return res;
// }
// };
I3ByYWdtYSBHQ0Mgb3B0aW1pemUgKCJPZmFzdCIpCiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnRlbXBsYXRlPGNsYXNzIFMsIGNsYXNzIFQ+IGlubGluZSBTIG1pbl9MKFMgYSxUIGIpewogIHJldHVybiBhPD1iP2E6YjsKfQojZGVmaW5lIG1haW4gZHVtbXlfbWFpbgppbnQgbWFpbigpewogIHJldHVybiAwOwp9CiN1bmRlZiBtYWluCmNsYXNzIFNvbHV0aW9uewogIHB1YmxpYzoKICB2ZWN0b3I8aW50PiBhcnJheXNJbnRlcnNlY3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JiBiIDwgQi5zaXplKCkgJiYgYyA8IEMuc2l6ZSgpKXsKLy8gICAgICAgaWYoQVthXSA9PSBCW2JdID09IENbY10pewovLyAgICAgICAgIHJlcy5wdXNoX2JhY2soQVthXSk7Ci8vICAgICAgICAgYSsrOyBiKys7IGMrKzsKLy8gICAgICAgfSBlbHNlIHsKLy8gICAgICAgICBtID0gbWluKEFbYV0sIEJbYl0sIENbY10pOwovLyAgICAgICAgIGlmKG09PUFbYV0pIGErKzsKLy8gICAgICAgICBpZihtPT1CW2JdKSBiKys7Ci8vICAgICAgICAgaWYobT09Q1tjXSkgYysrOwovLyAgICAgICB9Ci8vICAgICB9Ci8vICAgICByZXR1cm4gcmVzOwovLyAgIH0KLy8gfTsK