제출 #1097898

#제출 시각아이디문제언어결과실행 시간메모리
1097898nathan4690Genetics (BOI18_genetics)C++14
100 / 100
265 ms33640 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define el cout << '\n' #define f1(i,n) for(int i=1;i<=n;i++) #define __file_name "" using namespace std; const ll maxn = 4105, inf=1e18, mod=1e9+7; ll n,m,k, val[maxn][4]; string s[maxn]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); if(fopen(__file_name ".inp", "r")){ freopen(__file_name ".inp","r",stdin); freopen(__file_name ".out","w",stdout); } // code here cin >> n >> m >> k; // A: 0, T: 1, G: 2, C: 3 ll pw = 1, sum = 0; f1(i,n){ cin >> s[i]; s[i] = ' ' + s[i]; sum = (sum + pw) % mod; f1(j, m){ if(s[i][j] == 'A'){ val[j][2] += pw; val[j][3] += pw; val[j][4] += pw; }else if(s[i][j] == 'T'){ val[j][1] += pw; val[j][3] += pw; val[j][4] += pw; }else if(s[i][j] == 'G'){ val[j][2] += pw; val[j][1] += pw; val[j][4] += pw; }else if(s[i][j] == 'C'){ val[j][2] += pw; val[j][3] += pw; val[j][1] += pw; } } pw = (pw * (m + 1)) % mod; } pw = 1; f1(i,n){ ll cur = 0; f1(j,m){ if(s[i][j] == 'A') cur += val[j][1]; if(s[i][j] == 'T') cur += val[j][2]; if(s[i][j] == 'G') cur += val[j][3]; if(s[i][j] == 'C') cur += val[j][4]; } cur %= mod; ll target = ((sum - pw + mod) * k) % mod; if(target == cur){ cout << i;el; return 0; } pw = (pw * (m+1)) % mod; } return 0; }

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

genetics.cpp: In function 'int main()':
genetics.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(__file_name ".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen(__file_name ".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:40:27: warning: array subscript 4 is above array bounds of 'long long int [4]' [-Warray-bounds]
   40 |                 val[j][4] += pw;
      |                 ~~~~~~~~~~^~~~~
genetics.cpp:40:27: warning: array subscript 4 is above array bounds of 'long long int [4]' [-Warray-bounds]
genetics.cpp:36:27: warning: array subscript 4 is above array bounds of 'long long int [4]' [-Warray-bounds]
   36 |                 val[j][4] += pw;
      |                 ~~~~~~~~~~^~~~~
genetics.cpp:36:27: warning: array subscript 4 is above array bounds of 'long long int [4]' [-Warray-bounds]
genetics.cpp:32:27: warning: array subscript 4 is above array bounds of 'long long int [4]' [-Warray-bounds]
   32 |                 val[j][4] += pw;
      |                 ~~~~~~~~~~^~~~~
genetics.cpp:32:27: warning: array subscript 4 is above array bounds of 'long long int [4]' [-Warray-bounds]
genetics.cpp:56:47: warning: array subscript 4 is above array bounds of 'long long int [4]' [-Warray-bounds]
   56 |             if(s[i][j] == 'C') cur += val[j][4];
      |                                       ~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...