Submission #466360

#TimeUsernameProblemLanguageResultExecution timeMemory
466360Namnamseo복사 붙여넣기 2 (JOI15_copypaste2)C++17
100 / 100
194 ms8532 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...