Submission #153146

#TimeUsernameProblemLanguageResultExecution timeMemory
153146SwanGenetics (BOI18_genetics)C++14
100 / 100
1317 ms19064 KiB
#include <bits/stdc++.h> #define stop system("pause") #define INP freopen("input.txt","r",stdin) #define OUTP freopen("solve1.txt","w",stdout) using namespace std; typedef long long ll; const int maxn = 4111; int cnt[maxn][5]; int n,m,k; struct st{ string s; int id; st(string a,int b){ s = a; id = b; } }; bool cmp(string& a,string& b){ int res = 0; for(int i(0); i < a.size();i++){ if(a[i]!=b[i])res++; } return res == k; } int get_num(char c){ if(c == 'A')return 0; if(c == 'C')return 1; if(c == 'T')return 2; return 3; } main() { ios_base::sync_with_stdio(0); cin >> n >> m >> k; int need = (n-1)*k; vector<st> v; for(int i(0); i < n;i++){ string s; cin >> s; v.push_back({s,i}); for(int j(0); j < s.size();j++){ cnt[j][get_num(s[j])]++; } } mt19937 gen(0); shuffle(v.begin(),v.end(),gen); //cout << endl; //for(int i(0); i < n;i++)cout << v[i].s << endl; for(int i(0); i < n;i++){ int all = 0; for(int j(0); j < v[i].s.size();j++){ int now = get_num(v[i].s[j]); for(int e(0); e < 4;e++){ if(e == now)continue; all+=cnt[j][e]; } } //cout << i+1 << ' ' << all << ' ' << need << endl; if(all!=need)continue; bool f = 1; for(int j(0); j < n;j++){ if(i == j)continue; if(!cmp(v[i].s,v[j].s)){ f = 0; break; } } if(f){ cout << v[i].id+1; return 0; } } return 0; } /* */

Compilation message (stderr)

genetics.cpp: In function 'bool cmp(std::__cxx11::string&, std::__cxx11::string&)':
genetics.cpp:25:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i(0); i < a.size();i++){
                   ~~^~~~~~~~~~
genetics.cpp: At global scope:
genetics.cpp:38:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
genetics.cpp: In function 'int main()':
genetics.cpp:47:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j(0); j < s.size();j++){
                       ~~^~~~~~~~~~
genetics.cpp:57:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j(0); j < v[i].s.size();j++){
                       ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...