Submission #1130271

#TimeUsernameProblemLanguageResultExecution timeMemory
1130271Ak_16Mutating DNA (IOI21_dna)C++20
Compilation error
0 ms0 KiB
#include <iostream> #include <string> using namespace std; void init(string a, string b){ int n = a.size(); int paa[100005] int pac[100005]; int pat[100005]; int pca[100005]; int pcc[100005]; int pct[100005]; int pta[100005]; int ptc[100005]; int ptt[100005]; paa[0]=0; pac[0]=0; pat[0]=0; pca[0]=0; pcc[0]=0; pct[0]=0; pta[0]=0; ptc[0]=0; ptt[0]=0; for(int i=1; i<=n; i++){ paa[i] = paa[i-1]; pac[i] = pac[i-1]; pat[i] = pat[i-1]; pca[i] = pca[i-1]; pcc[i] = pcc[i-1]; pct[i] = pct[i-1]; pta[i] = pta[i-1]; ptc[i] = ptc[i-1]; ptt[i] = ptt[i-1]; if(a[i-1]=='A'&&b[i-1]=='A'){paa[i]++;} if(a[i-1]=='A'&&b[i-1]=='C'){pac[i]++;} if(a[i-1]=='A'&&b[i-1]=='T'){pat[i]++;} if(a[i-1]=='C'&&b[i-1]=='A'){pca[i]++;} if(a[i-1]=='C'&&b[i-1]=='C'){pcc[i]++;} if(a[i-1]=='C'&&b[i-1]=='T'){pct[i]++;} if(a[i-1]=='T'&&b[i-1]=='A'){pta[i]++;} if(a[i-1]=='T'&&b[i-1]=='C'){ptc[i]++;} if(a[i-1]=='T'&&b[i-1]=='T'){ptt[i]++;} } } int get_distance(int x, int y){ x++; y++; int n1 = paa[y] - paa[x-1]; int n2 = pac[y] - pac[x-1]; int n3 = pat[y] - pat[x-1]; int n4 = pca[y] - pca[x-1]; int n5 = pcc[y] - pcc[x-1]; int n6 = pct[y] - pct[x-1]; int n7 = pta[y] - pta[x-1]; int n8 = ptc[y] - ptc[x-1]; int n9 = ptt[y] - ptt[x-1]; if(n2+n3!=n4+n7){return -1;} if(n4+n6!=n2+n8){return -1;} if(n7+n8!=n3+n6){return -1;} int ans = 0; n1 = 0; n5 = 0; n9 = 0; int m1 = min(n2, n4); int m2 = min(n3, n7); int m3 = min(n6, n8); ans += m1 + m2 + m3; n2 -= m1; n4 -= m1; n3 -= m2; n7 -= m2; n6 -= m3; n8 -= m3; ans += ( (n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9) * 2 / 3) ; return ans; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:7:19: error: expected initializer before 'int'
    7 |   int paa[100005] int pac[100005]; int pat[100005]; int pca[100005];
      |                   ^~~
dna.cpp:9:3: error: 'paa' was not declared in this scope; did you mean 'pta'?
    9 |   paa[0]=0;
      |   ^~~
      |   pta
dna.cpp:10:3: error: 'pac' was not declared in this scope; did you mean 'ptc'?
   10 |   pac[0]=0;
      |   ^~~
      |   ptc
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:45:12: error: 'paa' was not declared in this scope
   45 |   int n1 = paa[y] - paa[x-1];
      |            ^~~
dna.cpp:46:12: error: 'pac' was not declared in this scope
   46 |   int n2 = pac[y] - pac[x-1];
      |            ^~~
dna.cpp:47:12: error: 'pat' was not declared in this scope
   47 |   int n3 = pat[y] - pat[x-1];
      |            ^~~
dna.cpp:48:12: error: 'pca' was not declared in this scope
   48 |   int n4 = pca[y] - pca[x-1];
      |            ^~~
dna.cpp:49:12: error: 'pcc' was not declared in this scope
   49 |   int n5 = pcc[y] - pcc[x-1];
      |            ^~~
dna.cpp:50:12: error: 'pct' was not declared in this scope
   50 |   int n6 = pct[y] - pct[x-1];
      |            ^~~
dna.cpp:51:12: error: 'pta' was not declared in this scope
   51 |   int n7 = pta[y] - pta[x-1];
      |            ^~~
dna.cpp:52:12: error: 'ptc' was not declared in this scope; did you mean 'putc'?
   52 |   int n8 = ptc[y] - ptc[x-1];
      |            ^~~
      |            putc
dna.cpp:53:12: error: 'ptt' was not declared in this scope
   53 |   int n9 = ptt[y] - ptt[x-1];
      |            ^~~