Submission #128514

# Submission time Handle Problem Language Result Execution time Memory
128514 2019-07-11T05:04:16 Z 윤교준(#3160) None (JOI16_ho_t4) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmin(a,b) (a)=min((a),(b))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100055;

namespace TC1 {
	int *B, *C, N;

	void solve(int *_B, int *_C, int _N) {
		B = _B; C = _C; N = _N;

		set<pii> V;
		for(int i = 0; i < N; i++) V.insert({B[i], C[i]});

		int ret = 0;
		for(auto &v : V) {
			bool flag = false;
			for(int dy : {0, 1}) for(int dx : {0, 1}) {
				int y = v.first+dy, x = v.second+dx;
				auto it = V.find({y, x});
				if(V.end() == it) {
					flag = true;
					break;
				}
			}
			if(!flag) ret++;
		}

		cout << ret << endl;
		exit(0);
	}
}

int B[MAXN], C[MAXN];
char A[MAXN];

int N, K;

int main() {
	scanf("%d%d %s", &N, &K, A+1);
	for(int i = 1; i <= N; i++) {
		if('N' == A[i]) C[i]--;
		if('S' == A[i]) C[i]++;
		if('E' == A[i]) B[i]--;
		if('W' == A[i]) B[i]++;
		B[i] += B[i-1];
		C[i] += C[i-1];
	}
	if(1 == K || (!B[N] && !C[N])) TC1::solve(B, C, N);
	return 0;
}

Compilation message

2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:49:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d %s", &N, &K, A+1);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -