Submission #28556

#TimeUsernameProblemLanguageResultExecution timeMemory
28556이제 내가 두목이다~ (#68)Play Onwards (FXCUP2_onward)C++11
1 / 1
29 ms2296 KiB
#include <iostream> #include <cstdio> #include <string> #include <vector> #include <queue> #include <stack> #include <algorithm> using namespace std; vector<int> adj[202]; int dic[202]; string str[202]; bool flag = true; void dfs(int x, int c) { if(dic[x] != c && dic[x] != 0) { flag = false; return; } if(dic[x] == c) return; if(!flag) return; dic[x] = c; for(int nxt : adj[x]) { dfs(nxt, c == 1 ? 2 : 1); } } int asdf(string s, string t, int k) { if(s.size() < k || t.size() < k) return 0; for(int i=0; i<(int)s.size()-k+1; i++) { string a = s.substr(i, k); if(t.find(a) != string::npos) return 1; } return 0; } 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(asdf(str[i], str[j], k) || asdf(str[j], str[i], k)) { adj[j].push_back(i); adj[i].push_back(j); } } } for(int i=0; i<n; i++) { if(dic[i] == 0) dfs(i, 1); } if(flag) { cout << "Yes\n"; if(count(dic, dic+n, 1) == n) dic[0] = 2; for(int i=0; i<n; i++) cout << dic[i] << '\n'; } else cout << "No\n"; return 0; }

Compilation message (stderr)

onward.cpp: In function 'int asdf(std::__cxx11::string, std::__cxx11::string, int)':
onward.cpp:34:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(s.size() < k || t.size() < k) return 0;
                 ^
onward.cpp:34:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(s.size() < k || t.size() < k) return 0;
                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...