제출 #1261359

#제출 시각아이디문제언어결과실행 시간메모리
1261359Charizard2021Genetics (BOI18_genetics)C++20
27 / 100
39 ms3912 KiB
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m, val;
    cin >> n >> m >> val;
    vector<string> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    if(n <= 100 && m <= 100){
        for(int i = 0; i < n; i++){
            bool works = true;
            for(int j = 0; j < n; j++){
                if(j == i){
                    continue;
                }
                int ans = 0;
                for(int k = 0; k < m; k++){
                    if(v[i][k] != v[j][k]){
                        ans++;
                    }
                }
                if(ans != val){
                    works = false;
                    break;
                }
            }
            if(works){
                cout << i + 1 << "\n";
                return 0;
            }
        }
    }
    else{
        bitset<4101> bit[n];
        for(int i = 0; i < n; i++){
            for(int j =0 ; j < m; j++){
                bit[i][j] = (v[i][j] == 'A');
            }
        }
        for(int i = 0; i < n; i++){
            bool works = true;
            for(int j = 0; j < min(n, 500); j++){
                if(j == i){
                    continue;
                }
                int thingy = (bit[i] ^ bit[j]).count();
                if(thingy != val){
                    works = false;
                    break;
                }
            }
            if(works){
                cout << i + 1 << "\n";
                return 0;
            }
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...