제출 #1274702

#제출 시각아이디문제언어결과실행 시간메모리
1274702Davdav1232Genetics (BOI18_genetics)C++20
100 / 100
691 ms20084 KiB
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vii;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, k; cin>>n>>m>>k;
    vector<pair<string, int>> villains(n);
    for(int i=0; i<n; i++){
        cin>>villains[i].first;
        villains[i].second=i+1;
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(villains[i].first[j]=='A') villains[i].first[j]-='A';
            if(villains[i].first[j]=='C') villains[i].first[j]-='C'-1;
            if(villains[i].first[j]=='G') villains[i].first[j]-='G'-2;
            if(villains[i].first[j]=='T') villains[i].first[j]-='T'-3;
        }
    }
    vector<bool> is_real(n, 1);
    int rounds=30;
    while(rounds--){
        vector<vector<int>> count(m, vector<int> (4, 0));
        random_shuffle(villains.begin(), villains.end());
        for(int i=0; i<n; i++){
            int curr=i*k;
            for(int j=0; j<m; j++){
                curr-=i-count[j][villains[i].first[j]];
                count[j][villains[i].first[j]]++;
            }
            if(curr!=0){
                is_real[villains[i].second-1]=0;
            }
        }
    }
    for(int i=0; i<n; i++){
        if(is_real[i]){
            cout<<i+1;
            return 0;
        }
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

genetics.cpp: In function 'int main()':
genetics.cpp:28:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pair<__cxx11::basic_string<char>, int>*, vector<pair<__cxx11::basic_string<char>, int> > >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   28 |         random_shuffle(villains.begin(), villains.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from genetics.cpp:2:
/usr/include/c++/13/bits/stl_algo.h:4581:5: note: declared here
 4581 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...