Submission #28241

#TimeUsernameProblemLanguageResultExecution timeMemory
28241三( ε:) (#68)Play Onwards (FXCUP2_onward)C++14
0 / 1
36 ms2304 KiB
#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 (stderr)

onward.cpp: In function 'bool comp(const string&, const string&, int)':
onward.cpp:11:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i <= s1.size() - k; i++)
                       ^
onward.cpp:16:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int j = 0; j <= s2.size() - k; j++)
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...