답안 #677375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677375 2023-01-03T06:44:30 Z qwerasdfzxcl 복사 붙여넣기 2 (JOI15_copypaste2) C++17
100 / 100
194 ms 8556 KB
#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

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);
      |                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 316 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 368 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 316 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 368 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 183 ms 8456 KB Output is correct
10 Correct 88 ms 8492 KB Output is correct
11 Correct 91 ms 8556 KB Output is correct
12 Correct 194 ms 8376 KB Output is correct
13 Correct 82 ms 8272 KB Output is correct
14 Correct 82 ms 8288 KB Output is correct
15 Correct 88 ms 8312 KB Output is correct
16 Correct 84 ms 8204 KB Output is correct
17 Correct 186 ms 8160 KB Output is correct
18 Correct 67 ms 8396 KB Output is correct
19 Correct 59 ms 8404 KB Output is correct
20 Correct 62 ms 8328 KB Output is correct
21 Correct 68 ms 8324 KB Output is correct
22 Correct 77 ms 8396 KB Output is correct
23 Correct 87 ms 8440 KB Output is correct
24 Correct 104 ms 8396 KB Output is correct
25 Correct 152 ms 8524 KB Output is correct
26 Correct 186 ms 8328 KB Output is correct