Submission #520171

#TimeUsernameProblemLanguageResultExecution timeMemory
520171Killer2501Genetics (BOI18_genetics)C++14
19 / 100
482 ms71624 KiB
#include <bits/stdc++.h> #define ll int #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+50; const int M = 21; const ll inf = 4e9; const ll 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 == 'U')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(); }

Compilation message (stderr)

genetics.cpp:13:16: warning: overflow in conversion from 'double' to 'int' changes value from '4.0e+9' to '2147483647' [-Woverflow]
   13 | const ll inf = 4e9;
      |                ^~~
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...