Click Here to go back to the homepage.

Set! Solution:


#include <bits/stdc++.h>
using namespace std;


int main(){
    // #ifndef TESTING
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    char cards[12][4];
    for(int i = 0; i < 12; i++){
        for(int j = 0; j < 4; j++){
            cin >>cards[i][j];
        }
    }
    bool found = false;
    for(int i = 0; i < 10; i++){
        for(int j = i + 1; j < 11; j++){
            for(int k = j + 1; k < 12; k++){
                bool set = true;
                for(int l = 0; l < 4; l++){
                    if((cards[i][l] == cards[j][l] && cards[i][l] == cards[k][l]) ||
                    cards[i][l] != cards[j][l] && cards[j][l] != cards[k][l] && cards[i][l] != cards[k][l]){
                        continue;
                    }
                    set = false;
                    break;
                }
                if(set){
                    found = true;
                    cout << i + 1 << " " << j + 1 << " " << k + 1 << endl;
                }
            }
        }
    }
    if(!found){
        cout << "no sets" << endl;
    }
    
    return 0;   
}