Submission #1189594

#TimeUsernameProblemLanguageResultExecution timeMemory
1189594rendelMutating DNA (IOI21_dna)C++20
Compilation error
0 ms0 KiB
#include "dna.h" using namespace std; const int maxn = 1e5+5; string s1,s2; int l1,l2,cnt; int c1[maxn][3],c2[maxn][3]; void init(string a, string b) { s1=a; s2=b; l1=s1.length(),l2=s2.length(); for(int i=0;i<l1;++i){ if(s1[i]=='C') c1[i+1][0]++; else if(s1[i]=='A') c1[i+1][1]++; else if(s1[i]=='T') c1[i+1][2]++; } for(int i=0;i<l2;++i){ if(s2[i]=='C') c2[i+1][0]++; else if(s2[i]=='A') c2[i+1][1]++; else if(s2[i]=='T') c2[i+1][2]++; } } int get_distance(int x, int y) { for(int i=0;i<3;++i){ if(c1[y+1][i]-c1[x][i]!=c2[y+1][i]-c2[x][i]) return -1; } s1[i]!=s1[j] && s2[i]!=s2[j] cnt=0; for(int i=x;i<=y;++i){ for(int j=x;j<=y;++j){ if(s1[i]!=s2[j] && i!=j && s1[i]!=s2[i] && s1[j]!=s2[j]){ swap(s1[i],s1[j]); cnt++; } } } return cnt; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:28:12: error: 'i' was not declared in this scope
   28 |         s1[i]!=s1[j] && s2[i]!=s2[j]
      |            ^
dna.cpp:28:19: error: 'j' was not declared in this scope
   28 |         s1[i]!=s1[j] && s2[i]!=s2[j]
      |                   ^