Submission #417756

# Submission time Handle Problem Language Result Execution time Memory
417756 2021-06-04T08:44:47 Z 송준혁(#7519) RPS string (innopolis2021_final_C) C++17
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define MOD 1000000007
#define INF (1ll<<62)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

int TC, N;
char S[505050];
bool RP[505050], PP[505050], SP[505050];
bool RS[505050], PS[505050], SS[505050];

int main(){
	scanf("%d", &TC);
	while (TC--){
		int d;
		scanf("%d %s", &d, S+1);
		N = strlen(S+1);
		for (int i=1; i<=N; i++){
			RP[i] = PP[i] = SP[i] = false;
			if (S[i] == 'r') RP[i] = true;
			if (S[i] == 'p') PP[i] = true;
			if (S[i] == 's') SP[i] = true;
			RP[i] = RP[i-1] || RP[i];
			PP[i] = PP[i-1] || PP[i];
			SP[i] = SP[i-1] || SP[i];
		}
		RP[N+1] = PP[N+1] = SP[N+1] = false;
		for (int i=N; i>=1; i--){
			RP[i] = PP[i] = SP[i] = false;
			if (S[i] == 'r') RS[i] = true;
			if (S[i] == 'p') PS[i] = true;
			if (S[i] == 's') SS[i] = true;
			RS[i] = RS[i+1] || RS[i];
			PS[i] = PS[i+1] || PS[i];
			SS[i] = SS[i+1] || SS[i];
		}
		for (int i=1; i<=N; i++){
			if (S[i] == 'r') printf("%d", !((PP[i-1] && !SP[i-1]) || (PS[i+1] && !SS[i+1])));
			if (S[i] == 'p') printf("%d", !((SP[i-1] && !RP[i-1]) || (SS[i+1] && !RS[i+1])));
			if (S[i] == 's') printf("%d", !((RP[i-1] && !PP[i-1]) || (RS[i+1] && !PS[i+1])));
		}
		printf("\n");
	}
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d", &TC);
      |  ~~~~~^~~~~~~~~~~
Main.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d %s", &d, S+1);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -