Submission #158562

#TimeUsernameProblemLanguageResultExecution timeMemory
158562jvalsortavZamjena (COCI18_zamjena)C++14
14 / 70
45 ms5864 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; string s, h; map <string, vector <string> > m; vector <string> v[2]; map <string, int> vis; bool inf = true; int intq(string a){ if (isdigit(a[0])) return 1; else return 0; } void dfs(string node, int c){ /*cout << node << " " << c << "\n";*/ if (c >= 2) inf = false; if (inf == false or vis[node]) return; vis[node] = 1; for (int i = 0; i < m[node].size(); i++){ dfs(m[node][i], c + intq(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++){ dfs(v[0][i], 0); dfs(v[1][i], 0); if (!inf) break; } if (inf) cout << "DA"; else cout << "NE"; return 0; }

Compilation message (stderr)

zamjena.cpp: In function 'void dfs(std::__cxx11::string, int)':
zamjena.cpp:54: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...