Submission #692222

#TimeUsernameProblemLanguageResultExecution timeMemory
692222thegamercoder19Mutating DNA (IOI21_dna)C++17
0 / 100
1585 ms18208 KiB
#include "dna.h" #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #define M_PI 3.14159265358979323846 #define FILER 0 using ll = long long; using ull = unsigned long long; using ld = long double; const ll MOD = pow(10, 9) + 7; const ll INFL = 0x3f3f3f3f3f3f3f3f; const ull INFUL = 0x3f3f3f3f3f3f3f3f; const ll INFT = 0x3f3f3f3f; const ull MAX = 1LL << 24; const ll MODD = 998244353; const double EPS = 1e-10; #define V vector #define pll pair<ll, ll> #define pull2 pair<ull,ull> #define MS multiset #define M map #define Q queue #define PQ priority_queue #define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c) #define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c) #define FORA(a,i) for(auto &i : a) #define all(v) v.begin(),v.end() #define sz(v) v.size() #define sorta(a) sort(all(a)) #define sortd(a) sort(all(a), greater<ll>()) #define setp(x) setprecision(x)<<fixed #define RET return #define log(a,b) log(b)/log(a) #define WH(s) while(s) #define WHI(t) WH(t--) #define YES cout<<"YES"<<endl; #define NO cout<<"NO"<<endl; #define Yes cout<<"Yes"<<endl; #define No cout<<"No"<<endl; #define YESNO(s) cout << (s ? "YES" : "NO") << endl; #define YesNo(s) cout<<(s?"Yes":"No")<<endl; #define TYP 0 using namespace std; V<pll> pa, pc, pt; V<ll> pf; V<V<ll>> g; V<bool> used; ll res,ia,ic,it; map<char, V<ll>> h; map<char, ll> ez; void dfs(ll u) { used[u] = 1; res++; FORA(g[u], v) { if (used[v])RET; dfs(v); } } void init(std::string a, std::string b) { ll n = a.size(); a = '$' + a, b = '$' + b; pa.resize(n + 1); pc.resize(n + 1); pt.resize(n + 1); pf.resize(n + 1); g.resize(n + 1); used.resize(n + 1); FOR(ll, i, 1, n + 1, 1) { if (b[i] != a[i])h[b[i]].push_back(i); //pa[i] = { pa[i - 1].first + (a[i] == 'A'), pa[i - 1].second + (b[i] == 'A') }; //pc[i] = { pc[i - 1].first + (a[i] == 'C'), pc[i - 1].second + (b[i] == 'C') }; //pt[i] = { pt[i - 1].first + (a[i] == 'T'), pt[i - 1].second + (b[i] == 'T') }; } FOR(ll, i, 1, n + 1, 1) { if (b[i] == a[i])continue; if (ez[a[i]] <= h[a[i]].size())g[i].push_back(h[a[i]][ez[a[i]]]), ez[a[i]]++; } FOR(ll, i, 1, n + 1, 1) { if (!used[i]) { res = 0; dfs(i); pf[i] = max(0LL,res-1); } pf[i] += pf[i - 1]; } } int get_distance(int x, int y) { x++, y++; for (auto a : { pa,pc,pt }) if (a[y].first - a[x - 1].first != a[y].second - a[x - 1].second)return -1; return pf[y] - pf[x - 1]; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:77:16: warning: comparison of integer expressions of different signedness: 'std::map<char, long long int>::mapped_type' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |   if (ez[a[i]] <= h[a[i]].size())g[i].push_back(h[a[i]][ez[a[i]]]), ez[a[i]]++;
#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...