Submission #682888

#TimeUsernameProblemLanguageResultExecution timeMemory
682888mansurMutating DNA (IOI21_dna)C++17
0 / 100
34 ms3276 KiB
#include<bits/stdc++.h> using namespace std; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define sz(a) a.size() #define pf push_front #define pb push_back #define vt vector #define s second #define f first #define nl '\n' using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; string a, b; void init(string A, string B) { a = A, b = B; } int get_distance(int x, int y) { vt<char> s; for (int i = x; i <= y; i++) s.pb(b[i]); int ans = 0; for (int i = x; i <= y; i++) { int ps = -1; for (int j = 0; j < sz(s); j++) { if (s[j] == a[i]) { ps = j; break; } } if (ps == -1) return -1; ans += ps; vt<char> h; for (int j = 0; j < sz(s); j++) { if (j == ps) continue; h.pb(s[j]); } swap(s, h); } return ans; } #ifdef MANSUR 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]); } return 0; } #endif

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for (int j = 0; j < sz(s); j++) {
      |                     ^
dna.cpp:41:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   for (int j = 0; j < sz(s); j++) {
      |                     ^
#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...