Submission #887664

#TimeUsernameProblemLanguageResultExecution timeMemory
887664nnhzzzGenetics (BOI18_genetics)C++14
46 / 100
2028 ms85228 KiB

#include<bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i = (a); i<=(b); ++i)
#define REPD(i,a,b) for(int i = (a); i>=(b); --i)
#define REPDIS(i,a,b,c) for(int i = (a); i<=(b); i += c)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define MASK(x) (1LL<<(x))
#define BIT(x,i) (((x)>>(i))&1LL)
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define pii pair<int,int>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define fi first
#define se second
#define gcd __gcd
#define ld long double
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define endl "\n"
//#define int ll

//-------------------------------------------------------------------------------------------------------//
int readInt(){
    char c;
    do{
        c = getchar();
    }while(c!='-' && !isdigit(c));
    bool neg = (c=='-');
    int res = neg?0:c-'0';
    while(isdigit(c=getchar())) res = (res<<3)+(res<<1)+(c-'0');
    return neg?-res:res;
}
//-------------------------------------------------------------------------------------------------------//
template<typename T> bool mini(T &a, const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> bool maxi(T &a, const T &b){if(a<b){a=b;return true;}return false;}
//-------------------------------------------------------------------------------------------------------//
const int MAXN = 4e3+123;
const int MOD = 1e9+7;
const int INF = 1e9;
const int LOG = 16;
const ll LINF = 5e17;
const ld EPS = 1e-9;
const ld PI = acos(-1);
//-------------------------------------------------------------------------------------------------------//

int a[MAXN][MAXN];
int n,m,k;

namespace sub1{

    void solve(){
        REP(l,1,n){
            int ok = 1;
            REP(i,1,n){
                if(i==l) continue;
                int cnt = 0;
                REP(j,1,m) if(a[l][j]!=a[i][j]) ++cnt;
                if(cnt!=k){
                    ok = 0;
                    break;
                }
            }
            if(ok){
                cout << l;
                return ;
            }
        }
    }
}

namespace sub2{
    bitset<MAXN> f[MAXN];

    void solve(){
        REP(i,1,n) REP(j,1,m) f[i][j] = a[i][j]-1;
        REP(l,1,n){
            int ok = 1;
            REP(i,1,n){
                if(i==l) continue;
                int cnt = (f[l]^f[i]).count();
                if(cnt!=k){
                    ok = 0;
                    break;
                }
            }
            if(ok){
                cout << l;
                return ;
            }
        }
    }
}

void solve(){
    cin >> n >> m >> k;
    int s2 = 1;
    REP(i,1,n){
        REP(j,1,m){
            char ch; cin >> ch;
            if(ch=='A') a[i][j] = 1;
            if(ch=='C') a[i][j] = 2;
            if(ch=='G') a[i][j] = 3;
            if(ch=='T') a[i][j] = 4;
            if(a[i][j]>2) s2 = 0;
        }
    }
    if(s2){
        sub2::solve();
        return ;
    }
    sub1::solve();
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define task "test"
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    #define task1 "nothing"
    if(fopen(task1".inp","r")){
        freopen(task1".inp","r",stdin);
        freopen(task1".out","w",stdout);
    }
    int test = 1;
    while(test--){
        solve();
        cout << endl;
    }
    return 0;
}

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:126:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  126 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:127:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  127 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:131:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  131 |         freopen(task1".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:132:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  132 |         freopen(task1".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...