Submission #28239

# Submission time Handle Problem Language Result Execution time Memory
28239 2017-07-16T04:06:23 Z AcornCkiGuiziTeam(#1202, dotorya, cki86201, zigui) Play Onwards (FXCUP2_onward) C++11
0 / 1
9 ms 2256 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb(x) push_back(x)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define Fi first
#define Se second

char A[220][220];
int n, k;
int E[220][220];
int L[220];
int color[220];

void dfs(int x, int c) {
	color[x] = c;
	rep(i, n) if(E[x][i]) {
		if(color[i] == 0) dfs(i, 3 - c);
	}
}

void solve() {
	scanf("%d%d", &n, &k);
	for(int i=0;i<n;i++) scanf("%s", A[i]);
	rep(i, n) L[i] = (int)strlen(A[i]);
	rep(i, n) rep(j, i){
		for(int u=0;u<=L[i]-k;u++) {
			for(int v=0;v<=L[j]-k;v++){
				int ok = 1;
				for(int a=0;a<k;a++) if(A[i][u+a] != A[j][v+a]) ok = 0;
				if(ok){ E[i][j] = E[j][i] = 1; break; }
			}
			if(E[i][j]) break;
		}
	}
	rep(i, n) if(color[i] == 0) {
		dfs(i, 1);
	}
	rep(i, n) rep(j, n) if(E[i][j] && color[i] == color[j]) {
		puts("No");
		return;
	}
	puts("Yes");
	rep(i, n) printf("%d\n", color[i]);
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++) {
	//	printf("Case #%d\n", tc);
		solve();
	}
	return 0;
};

Compilation message

onward.cpp: In function 'void solve()':
onward.cpp:44:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
                       ^
onward.cpp:45:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++) scanf("%s", A[i]);
                                        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2256 KB Output is correct
2 Correct 0 ms 2256 KB Output is correct
3 Correct 0 ms 2256 KB Output is correct
4 Correct 0 ms 2256 KB Output is correct
5 Correct 0 ms 2256 KB Output is correct
6 Correct 3 ms 2256 KB Output is correct
7 Correct 9 ms 2256 KB Output is correct
8 Correct 9 ms 2256 KB Output is correct
9 Correct 9 ms 2256 KB Output is correct
10 Correct 9 ms 2256 KB Output is correct
11 Incorrect 0 ms 2256 KB Output isn't correct
12 Halted 0 ms 0 KB -