fork download
  1. #include <vector>
  2. #include <string>
  3. using namespace std;
  4. int d[55];
  5. class TeamsSelection{
  6. public:
  7. string simulate(vector <int> preference1, vector <int> preference2){
  8. int N = preference1.size();
  9. for( int i=0; i<N; i++ ){
  10. if( i % 2 == 0 ){
  11. for( int j=0; j<N; j++ ){
  12. if( d[preference1[j]] ) continue;
  13. d[preference1[j]] = 1; break;
  14. }
  15. } else {
  16. for( int j=0; j<N; j++ ){
  17. if( d[preference2[j]] ) continue;
  18. d[preference2[j]] = 2; break;
  19. }
  20. }
  21. }
  22. string ret;
  23. for( int i=1; i<=N; i++ ){
  24. ret = ret + (char)('0'+d[i]);
  25. }
  26. return ret;
  27. }
  28. };
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty