Submission #1246262

#TimeUsernameProblemLanguageResultExecution timeMemory
1246262JerVim (BOI13_vim)C++20
2.78 / 100
1 ms840 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); char s[n + 1]; scanf("%s", s); vector<vector<int>> pos(10); for (int i = 0; i < n; i++) if (s[i] != 'e') pos[s[i] - 'a'].push_back(i); vector<int> epos; for (int i = 0; i < n; i++) if (s[i] == 'e') epos.push_back(i); int curr = 0, res = 0; for (int ei = 0; ei < epos.size(); ei++) { int target = epos[ei]; int min_steps = abs(curr - target); res += min_steps; curr = target; if (curr < n - 1) res++; } printf("%d\n", res); }

Compilation message (stderr)

vim.cpp: In function 'int main()':
vim.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
vim.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%s", s);
      |     ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...