Submission #542838

#TimeUsernameProblemLanguageResultExecution timeMemory
542838alexdumitruMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long long sa1[200005],st1[200005],sc1[200005],sa2[200005],st2[200005],sc2[200005]; long long pepoz[200005]; long long AT[200005]; long long AC[200005]; long long CA[200005]; long long CT[200005]; long long TA[200005]; long long TC[200005]; long long geta1(long long i, long long j) { if(!i)return sa1[j]; return sa1[j]-sa1[i-1]; } long long gett1(long long i, long long j) { if(!i)return st1[j]; return st1[j]-st1[i-1]; } long long getc1(long long i, long long j) { if(!i)return sc1[j]; return sc1[j]-sc1[i-1]; } long long geta2(long long i, long long j) { if(!i)return sa2[j]; return sa2[j]-sa2[i-1]; } long long getat(long long i, long long j) { if(!i)return AT[j]; return AT[j]-AT[i-1]; } long long getac(long long i, long long j) { if(!i)return AC[j]; return AC[j]-AC[i-1]; } long long getca(long long i, long long j) { if(!i)return CA[j]; return CA[j]-CA[i-1]; } long long getct(long long i, long long j) { if(!i)return CT[j]; return CT[j]-CT[i-1]; } long long getta(long long i, long long j) { if(!i)return TA[j]; return TA[j]-TA[i-1]; } long long gettc(long long i, long long j) { if(!i)return TC[j]; return TC[j]-TC[i-1]; } long long cate(long long i, long long j) { if(!i)return pepoz[j]; return pepoz[j]-pepoz[i-1]; } long long gett2(long long i, long long j) { if(!i)return st2[j]; return st2[j]-st2[i-1]; } long long getc2(long long i, long long j) { if(!i)return sc2[j]; return sc2[j]-sc2[i-1]; } bool samea(long long i, long long j) { return geta1(i,j)==geta2(i,j); } bool samet(long long i, long long j) { return gett1(i,j)==gett2(i,j); } bool samec(long long i, long long j) { return getc1(i,j)==getc2(i,j); } void init(string a, string b) { long long i,n; n=a.length(); sa1[0]=(a[0]=='A'); st1[0]=(a[0]=='T'); sc1[0]=(a[0]=='C'); for(i=1;i<n;i++) { sa1[i]=sa1[i-1]; st1[i]=st1[i-1]; sc1[i]=sc1[i-1]; if(a[i]=='A')sa1[i]++; else if(a[i]=='T')st1[i]++; else sc1[i]++; } sa2[0]=(b[0]=='A'); st2[0]=(b[0]=='T'); sc2[0]=(b[0]=='C'); pepoz[0]=(a[0]==b[0]); i=0; if(a[i]=='A') { if(b[i]=='T')AT[i]++; else if(b[i]=='C')AC[i]++; } if(a[i]=='C') { if(b[i]=='A')CA[i]++; else if(b[i]=='T')CT[i]++; } if(a[i]=='T') { if(b[i]=='A')TA[i]++; else if(b[i]=='C')TC[i]++; } for(i=1;i<n;i++) { sa2[i]=sa2[i-1]; st2[i]=st2[i-1]; sc2[i]=sc2[i-1]; if(b[i]=='A')sa2[i]++; else if(b[i]=='T')st2[i]++; else sc2[i]++; pepoz[i]=pepoz[i-1]+(a[i]==b[i]); AT[i]=AT[i-1]; AC[i]=AC[i-1]; CA[i]=CA[i-1]; CT[i]=CT[i-1]; TA[i]=TA[i-1]; TC[i]=TC[i-1]; if(a[i]=='A') { if(b[i]=='T')AT[i]++; else if(b[i]=='C')AC[i]++; } if(a[i]=='C') { if(b[i]=='A')CA[i]++; else if(b[i]=='T')CT[i]++; } if(a[i]=='T') { if(b[i]=='A')TA[i]++; else if(b[i]=='C')TC[i]++; } } } long long get_distance(long long x, long long y) { if(!samea(x,y)||!samet(x,y)||!samec(x,y))return -1; long long ans=y-x+1; long long swps=0; ans-=cate(x,y); swps+=min(getat(x,y),getta(x,y)); swps+=min(getac(x,y),getca(x,y)); swps+=min(getct(x,y),gettc(x,y)); long long rezolvate=swps*2; long long maitrebuie=ans-rezolvate; return max(0LL,maitrebuie-1)+swps; }

Compilation message (stderr)

/usr/bin/ld: /tmp/cck93iPR.o: in function `main':
grader.cpp:(.text.startup+0x39d): undefined reference to `get_distance(int, int)'
collect2: error: ld returned 1 exit status