Submission #466360

# Submission time Handle Problem Language Result Execution time Memory
466360 2021-08-19T02:00:41 Z Namnamseo 복사 붙여넣기 2 (JOI15_copypaste2) C++17
100 / 100
194 ms 8532 KB
#include <cstdio>
void read(int& x){ scanf("%d",&x); }
template<typename T,typename... Args>
void read(T&a,Args&...b){ read(a); read(b...); }

int k;
int pos[210];

char S[200010];

int n;
int qs[200010];
int qe[200010];
int qp[200010];

inline int app_pos(int bp,int S,int E,int P){
	int nl=P, nr=P+E-S;
	if(nl <= bp && bp <= nr){
		return S+bp-nl;
	} else if(bp < nl){
		return bp;
	} else {
		return bp-(E-S+1);
	}
}

int main(){
	scanf("%d%*d%s%d", &k, S, &n);
	for(int i=1; i<=n; ++i) read(qs[i], qe[i], qp[i]), --qe[i];
	for(int i=0; i<k; ++i) pos[i]=i;

	for(int i=n; 1<=i; --i){
		for(int j=0; j<k; ++j){
			pos[j] = app_pos(pos[j], qs[i], qe[i], qp[i]);
		}
	}

	for(int j=0; j<k; ++j) putchar(S[pos[j]]);
	putchar(10);

	return 0;
}

Compilation message

copypaste2.cpp: In function 'void read(int&)':
copypaste2.cpp:2:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | void read(int& x){ scanf("%d",&x); }
      |                    ~~~~~^~~~~~~~~
copypaste2.cpp: In function 'int main()':
copypaste2.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%d%*d%s%d", &k, S, &n);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 3 ms 300 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 2 ms 300 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 3 ms 300 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 2 ms 300 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 160 ms 8532 KB Output is correct
10 Correct 130 ms 8396 KB Output is correct
11 Correct 132 ms 8368 KB Output is correct
12 Correct 160 ms 8396 KB Output is correct
13 Correct 174 ms 8260 KB Output is correct
14 Correct 131 ms 8252 KB Output is correct
15 Correct 130 ms 8260 KB Output is correct
16 Correct 134 ms 8260 KB Output is correct
17 Correct 194 ms 8260 KB Output is correct
18 Correct 92 ms 8380 KB Output is correct
19 Correct 95 ms 8304 KB Output is correct
20 Correct 92 ms 8380 KB Output is correct
21 Correct 96 ms 8332 KB Output is correct
22 Correct 111 ms 8472 KB Output is correct
23 Correct 109 ms 8384 KB Output is correct
24 Correct 115 ms 8312 KB Output is correct
25 Correct 161 ms 8396 KB Output is correct
26 Correct 157 ms 8436 KB Output is correct