# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28241 | 三( ε:) (#68) | Play Onwards (FXCUP2_onward) | C++14 | 36 ms | 2304 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
string str[205];
vector<int> graph[205];
int vis[205];
bool comp(const string &s1, const string &s2, int k)
{
unordered_set<string> st;
for (int i = 0; i <= s1.size() - k; i++)
{
st.insert(s1.substr(i, k));
}
for (int j = 0; j <= s2.size() - k; j++)
{
if (st.count(s2.substr(j, k))) return true;
}
return false;
}
bool dfs(int t, int c)
{
vis[t] = c;
for (int nxt : graph[t])
{
if (vis[nxt] == 0)
{
if (dfs(nxt, c ^ 3) == false) return false;
}
else if (vis[nxt] == vis[t]) return false;
}
return true;
}
int main()
{
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++)
{
cin >> str[i];
}
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
if (comp(str[i], str[j], k))
{
graph[i].push_back(j);
graph[j].push_back(i);
}
}
}
int C = 1;
for (int i = 0; i < n; i++)
{
if (vis[i]) continue;
if (dfs(i, C) == false)
{
printf("No\n");
return 0;
}
else C ^= 3;
}
printf("Yes\n");
for (int i = 0; i < n; i++) printf("%d\n", vis[i]);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |