제출 #520172

#제출 시각아이디문제언어결과실행 시간메모리
520172Killer2501Genetics (BOI18_genetics)C++14
100 / 100
600 ms83676 KiB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
const int N = 4e3+150;
const int M = 21;
const ll inf = 4e9;
const int mod = 1e9+7;
int n, t, m, k, ans, tong, a[N][N], b[N], f[N][4];
pii dp[N];
vector<int> vi;
mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
void add(int &x, int y)
{
    x += y;
    if(x >= mod)x -= mod;
}
string s;
int get(char c)
{
    if(c == 'A')return 0;
    else if(c == 'C')return 1;
    else if(c == 'G')return 2;
    return 3;
}
void sol()
{
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i ++)b[i] = mt() % mod;
    char c;
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            cin >> c;
            a[i][j] = get(c);
            add(f[j][a[i][j]], b[i]);
        }
    }
    for(int i = 1; i <= n; i ++)
    {
        tong = 0;
        for(int j = 1; j <= n; j ++)if(i != j)add(tong, 1ll * b[j] * k % mod);
        ans = 0;
        for(int j = 1; j <= m; j ++)
        {
            for(int p = 0; p < 4; p ++)
            {
                if(p != a[i][j])add(ans, f[j][p]);
            }
        }
        if(ans == tong)
        {
            cout << i;
            return;
        }
    }
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    #define task "test"
    if(fopen(task".inp", "r"))
	{
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
    }
    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();
}

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

genetics.cpp: In function 'int main()':
genetics.cpp:73:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:74:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |   freopen(task".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...