Submission #62823

#TimeUsernameProblemLanguageResultExecution timeMemory
62823SpaimaCarpatilorGenetics (BOI18_genetics)C++17
100 / 100
421 ms21068 KiB
#include<bits/stdc++.h> using namespace std; int N, M, K; char sir[5009][5009]; long long coef[5000], f[5009][4]; int code (char c) { if (c == 'A') return 0; if (c == 'C') return 1; if (c == 'G') return 2; return 3; } int rand15 () {return rand () & 32767;} int rand30 () {return (rand15 () << 15) | rand15 ();} long long rand60 () {return ((long long) rand30 () * (1LL << 30)) | rand30 ();} int main () { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); srand (time (0)); scanf ("%d %d %d\n", &N, &M, &K); for (int i=1; i<=N; i++) coef[i] = rand60 (); for (int i=1; i<=N; i++) { scanf ("%s", sir[i] + 1); for (int j=1; j<=M; j++) sir[i][j] = code (sir[i][j]), f[j][sir[i][j]] += coef[i]; } for (int i=1; i<=N; i++) { long long needed = 0, curr = 0; for (int j=1; j<=N; j++) if (j != i) needed += 1LL * K * coef[j]; for (int j=1; j<=M; j++) for (int k=0; k<4; k++) if (k != sir[i][j]) curr += f[j][k]; if (curr == needed) { printf ("%d\n", i); return 0; } } return 0; }

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:35:23: warning: array subscript has type 'char' [-Wchar-subscripts]
         f[j][sir[i][j]] += coef[i];
                       ^
genetics.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d %d %d\n", &N, &M, &K);
 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:32:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%s", sir[i] + 1);
     ~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...