Submission #158563

#TimeUsernameProblemLanguageResultExecution timeMemory
158563jvalsortavZamjena (COCI18_zamjena)C++14
70 / 70
357 ms16220 KiB
#include <cstdio> #include <cstdlib> #include <cmath> #include <iostream> #include <cctype> #include <ctime> #include <set> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <utility> #include <string> #include <map> #include <iterator> #define ll long long #define mp make_pair using namespace std; const int M = 1000000007; ll pot(ll A, ll B){ ll R = 1; while (B){ if (B&1) R *= A; R %= M; A *= A; A %= M; B >>= 1; } return R; } int n; int c; string s, h; map <string, vector <string> > m; vector <string> v[2]; map <string, int> vis; bool inf = true; void dfs(string node){ if (vis[node]) return; /*cout << node << " " << c << "\n";*/ if (isdigit(node[0])) c++; if (c >= 2) inf = false; if (inf == false) return; vis[node] = 1; for (int i = 0; i < m[node].size(); i++){ dfs(m[node][i]); } return; } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < 2*n; i++){ cin >> s; v[i/n].push_back(s); vis[s] = 0; } for (int i = 0; i < n; i++){ s = v[0][i]; h = v[1][i]; m[s].push_back(h); m[h].push_back(s); } for (int i = 0; i < n; i++){ c = 0; dfs(v[0][i]); c = 0; dfs(v[1][i]); if (!inf) break; } if (inf) cout << "DA"; else cout << "NE"; return 0; }

Compilation message (stderr)

zamjena.cpp: In function 'void dfs(std::__cxx11::string)':
zamjena.cpp:50:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < m[node].size(); i++){
                  ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...