# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28280 | 쥬니님일어나세요 버스운전해주시기로했잖아요 (#68) | Play Onwards (FXCUP2_onward) | C++14 | 9 ms | 2300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <deque>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()
#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)
#define INF 987654321
#define IINF 987654321987654321
#define MAXV 200500
#define MOD 1234567
int N,M,K,T;
vector<int> E[300];
string s[300];
int color[300];
bool vis[300];
bool chk(string a, string b){
int ap = 0, bp=0;
for(ap=0;ap+K-1<sz(a);ap++){
for(bp=0;bp+K-1<sz(b);bp++){
bool ok = true;
for(int i=0;i<K;i++){
if( a[ap+i] != b[bp+i] ){
ok = false; break;
}
}
if( ok ) return true;
}
}
return false;
}
void dfs(int x, int c){
color[x] = c; vis[x] = true;
for(auto e: E[x])if(!vis[e]){
dfs(e,c^1);
}
}
int main(){
geti(N,K);
repp(i,N){
string x; cin >> x; s[i] = x;
}
repp(i,N)repp(j,N)if(i>j){
if ( chk(s[i],s[j]) ) {
E[i].pb(j); E[j].pb(i);
}
}
int cur = 1;
repp(i,N){
if( !vis[i] ){
dfs(i,cur);
cur ^= 1;
}
}
repp(i,N){
for(auto e : E[i]){
if( color[i] == color[e] ){
printf("No"); return 0;
}
}
}
printf("Yes\n");
repp(i,N){
printf("%d\n",color[i]+1);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |