Submission #998131

#TimeUsernameProblemLanguageResultExecution timeMemory
998131MilosMilutinovicBliskost (COI23_bliskost)C++14
100 / 100
181 ms16004 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, q; char s[N], t[N]; int main() { scanf("%d%d", &n, &q); scanf("%s", s + 1); scanf("%s", t + 1); int d = 0; for (int i = 1; i < n; i++) d = (d + (t[i] - 'a') * (i % 2 == (n - 1) % 2 ? 1 : -1) + (s[i] - 'a') * (i % 2 == (n - 1) % 2 ? -1 : 1) + 52) % 26; if (((((int) (s[n] + d) % 26) + 52) % 26) == ((int) t[n] % 26)) printf("da\n"); else printf("ne\n"); while (q--) { int p; char c; scanf("%d %c", &p, &c); if (p < n) d = (d - ((t[p] - 'a') * (p % 2 == (n - 1) % 2 ? 1 : -1) + (s[p] - 'a') * (p % 2 == (n - 1) % 2 ? -1 : 1)) + 52) % 26; s[p] = c; if (p < n) d = (d + (t[p] - 'a') * (p % 2 == (n - 1) % 2 ? 1 : -1) + (s[p] - 'a') * (p % 2 == (n - 1) % 2 ? -1 : 1) + 52) % 26; if (((((int) (s[n] + d) % 26) + 52) % 26) == ((int) t[n] % 26)) printf("da\n"); else printf("ne\n"); } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d%d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%s", s + 1);
      |     ~~~~~^~~~~~~~~~~~~
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%s", t + 1);
      |     ~~~~~^~~~~~~~~~~~~
Main.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d %c", &p, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...