# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28241 | 2017-07-16T04:07:27 Z | 三( ε:)(#1146, xdoju, veckal, unused) | Play Onwards (FXCUP2_onward) | C++14 | 36 ms | 2304 KB |
#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]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2040 KB | Output is correct |
2 | Correct | 0 ms | 2040 KB | Output is correct |
3 | Correct | 0 ms | 2040 KB | Output is correct |
4 | Correct | 0 ms | 2040 KB | Output is correct |
5 | Correct | 6 ms | 2304 KB | Output is correct |
6 | Correct | 23 ms | 2304 KB | Output is correct |
7 | Correct | 29 ms | 2040 KB | Output is correct |
8 | Correct | 33 ms | 2040 KB | Output is correct |
9 | Correct | 33 ms | 2040 KB | Output is correct |
10 | Correct | 36 ms | 2040 KB | Output is correct |
11 | Correct | 9 ms | 2040 KB | Output is correct |
12 | Correct | 36 ms | 2040 KB | Output is correct |
13 | Correct | 26 ms | 2040 KB | Output is correct |
14 | Correct | 16 ms | 2040 KB | Output is correct |
15 | Runtime error | 3 ms | 2180 KB | Execution killed because of forbidden syscall gettid (186) |
16 | Halted | 0 ms | 0 KB | - |