Submission #866168

#TimeUsernameProblemLanguageResultExecution timeMemory
866168lomtaMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int pref1[N],pref2[N],pref3[N]; void init(string a, string b) { int n=a.size(); pref1[0]=0; for(int i=0;i<n;i++){ pref1[i+1]=pref1[i]; if(a[i]=='A' && b[i]=='T'){ pref1[i+1]++; } if(a[i]=='T' && b[i]=='A'){ pref1[i+1]--; } } pref2[0]=0; for(int i=0;i<n;i++){ pref2[i+1]=pref2[i]; if(a[i]=='T' && b[i]=='C'){ pref2[i+1]++; } if(a[i]=='C' && b[i]=='T'){ pref2[i+1]--; } } pref3[0]=0; for(int i=0;i<n;i++){ pref3[i+1]=pref3[i]; if(a[i]=='C' && b[i]=='A'){ pref3[i+1]++; } if(a[i]=='A' && b[i]=='C'){ pref3[i+1]--; } } } int get_distance(int x, int y) { x++; y++; x--; int a1=pref1[y]-pref1[x]; int b1=pref2[y]-pref2[x]; int c1=pref3[y]-pref3[x]; if(a1!=b1 || b1!=c1 || c1!=a1){ return -1; } int sz=y-x; return (sz-abs(a1)-abs(b1)-abs(c1))/2+(abs(a1)+abs(b1)+abs(c1))/3*2; } int main() { int n, q; assert(scanf("%d %d", &n, &q) == 2); char A[n+1], B[n+1]; assert(scanf("%s", A) == 1); assert(scanf("%s", B) == 1); std::string a = std::string(A); std::string b = std::string(B); std::vector<int> x(q), y(q); for (int i = 0; i < q; i++) { assert(scanf("%d %d", &x[i], &y[i]) == 2); } fclose(stdin); std::vector<int> results(q); init(a, b); for (int i = 0; i < q; i++) { results[i] = get_distance(x[i], y[i]); } for (int i = 0; i < q; i++) { printf("%d\n", results[i]); } fclose(stdout); return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccOqAxYP.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccppt4vP.o:dna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status