Submission #677375

#TimeUsernameProblemLanguageResultExecution timeMemory
677375qwerasdfzxcl복사 붙여넣기 2 (JOI15_copypaste2)C++17
100 / 100
194 ms8556 KiB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
int n, m, k, q;
char s[200200];
int a[200200], b[200200], c[200200];

char calc(int pos, int dep){
    //printf(" %d %d\n", pos, dep);

    if (dep==0) return s[pos];
    if (c[dep] >= pos) return calc(pos, dep-1);
    int len = b[dep] - a[dep];
    if (c[dep]+len >= pos) return calc(a[dep] + pos - c[dep], dep-1);
    return calc(pos-len, dep-1);
}

int main(){
    scanf("%d %d", &k, &m);
    scanf("%s", s+1);
    n = strlen(s+1);
    scanf("%d", &q);
    for (int i=1;i<=q;i++) scanf("%d %d %d", a+i, b+i, c+i);

    for (int i=1;i<=k;i++) printf("%c", calc(i, q));
    return 0;
}

Compilation message (stderr)

copypaste2.cpp: In function 'int main()':
copypaste2.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d %d", &k, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
copypaste2.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%s", s+1);
      |     ~~~~~^~~~~~~~~~~
copypaste2.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
copypaste2.cpp:24:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     for (int i=1;i<=q;i++) scanf("%d %d %d", a+i, b+i, c+i);
      |                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...