답안 #28248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28248 2017-07-16T04:09:13 Z Sorry AcornCkiGuiziTeam(#1226, gs13068) Play Onwards (FXCUP2_onward) C++14
0 / 1
26 ms 1448 KB
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

char a[202][24];
int b[202];
vector<int> g[202];
int v[202], c[202];

int f(int x, int z) {
	if (v[x]) return c[x] != z;
	v[x] = 1;
	c[x] = z;
	for (auto t : g[x]) if (f(t, z ^ 1)) return 1;
	return 0;
}

int main() {
	int i, j, k, l, n, m, t;
	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%s", a[i]);
		b[i] = strlen(a[i]);
	}
	for (i = 0; i < n; i++) for (j = 0; j < i; j++) {
		for (k = -20; k <= 20; k++) {
			t = 0;
			for (l = 0; l < b[i]; l++) {
				if (l + k >= 0 && l + k < b[j] && a[i][l] == a[j][l + k]) t++;
				else t = 0;
				if (t >= m) break;
			}
			if (l < b[i]) break;
		}
		if (k <= 20) {
			g[i].push_back(j);
			g[j].push_back(i);
		}
	}
	for (i = 0; i < n; i++) if (!v[i] && f(i, 0)) {
		puts("No");
		return 0;
	}
	puts("Yes");
	for (i = 0; i < n; i++) printf("%d\n", c[i] + 1);
	return 0;
}

Compilation message

onward.cpp: In function 'int main()':
onward.cpp:22:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
                       ^
onward.cpp:24:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", a[i]);
                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1184 KB Output is correct
2 Correct 0 ms 1184 KB Output is correct
3 Correct 0 ms 1184 KB Output is correct
4 Correct 0 ms 1184 KB Output is correct
5 Correct 13 ms 1448 KB Output is correct
6 Correct 6 ms 1448 KB Output is correct
7 Correct 19 ms 1184 KB Output is correct
8 Correct 19 ms 1184 KB Output is correct
9 Correct 16 ms 1184 KB Output is correct
10 Correct 16 ms 1184 KB Output is correct
11 Incorrect 26 ms 1184 KB Output isn't correct
12 Halted 0 ms 0 KB -