Submission #495652

#TimeUsernameProblemLanguageResultExecution timeMemory
495652PedroBigManMutating DNA (IOI21_dna)C++17
100 / 100
60 ms11180 KiB
/* Author of all code: Pedro BIGMAN Dias Last edit: 15/02/2021 */ #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #pragma GCC optimize("Ofast") #include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <queue> #include <deque> #include <list> #include <iomanip> #include <stdlib.h> #include <time.h> #include <cstring> #include "dna.h" using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++) #define pb push_back #define mp make_pair #define pl pair<ll,ll> #define ff first #define ss second #define whole(x) x.begin(),x.end() #define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl #define INF 500000000LL #define EPS 0.00000001 #define pi 3.14159 #define VV(vvvv,NNNN,xxxx); REP(i,0,NNNN) {vvvv.pb(xxxx);} ll mod=1000000007LL; template<class A=ll> void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;} template<class A=ll> void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} vector<ll> ZAB, ZBA, ZAC, ZCA, ZBC, ZCB; ll N; vector<ll> A,B,C; void init(string a, string b) { N=a.size(); ll curZAB=0LL,curZBA=0LL,curZAC=0LL,curZCA=0LL,curZBC=0LL,curZCB=0LL,difA=0LL, difB=0LL, difC=0LL; REP(i,0,N) { if(a[i]=='A' && b[i]=='T') {curZAB++;} else if(a[i]=='T' && b[i]=='A') {curZBA++;} else if(a[i]=='A' && b[i]=='C') {curZAC++;} else if(a[i]=='C' && b[i]=='A') {curZCA++;} else if(a[i]=='T' && b[i]=='C') {curZBC++;} else if(a[i]=='C' && b[i]=='T') {curZCB++;} if(a[i]=='A') {difA++;} else if(a[i]=='T') {difB++;} else {difC++;} if(b[i]=='A') {difA--;} else if(b[i]=='T') {difB--;} else {difC--;} ZAB.pb(curZAB); ZBA.pb(curZBA); ZAC.pb(curZAC); ZCA.pb(curZCA); ZBC.pb(curZBC); ZCB.pb(curZCB); A.pb(difA); B.pb(difB); C.pb(difC); } } ll psAB(ll l, ll r) {if(l==0) {return ZAB[r];} else {return (ZAB[r]-ZAB[l-1]);}} ll psBA(ll l, ll r) {if(l==0) {return ZBA[r];} else {return (ZBA[r]-ZBA[l-1]);}} ll psAC(ll l, ll r) {if(l==0) {return ZAC[r];} else {return (ZAC[r]-ZAC[l-1]);}} ll psCA(ll l, ll r) {if(l==0) {return ZCA[r];} else {return (ZCA[r]-ZCA[l-1]);}} ll psBC(ll l, ll r) {if(l==0) {return ZBC[r];} else {return (ZBC[r]-ZBC[l-1]);}} ll psCB(ll l, ll r) {if(l==0) {return ZCB[r];} else {return (ZCB[r]-ZCB[l-1]);}} ll psA(ll l, ll r) {if(l==0) {return A[r];} else {return (A[r]-A[l-1]);}} ll psB(ll l, ll r) {if(l==0) {return B[r];} else {return (B[r]-B[l-1]);}} ll psC(ll l, ll r) {if(l==0) {return C[r];} else {return (C[r]-C[l-1]);}} int get_distance(int x, int y) { if(psA(x,y)!=0 || psB(x,y)!=0 || psC(x,y)!=0) {return -1;} return (2*max(psAB(x,y),psBA(x,y))-min(psAB(x,y),psBA(x,y))+min(psAC(x,y),psCA(x,y))+min(psBC(x,y),psCB(x,y))); }

Compilation message (stderr)

dna.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("O3")
      | 
dna.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...