#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
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 time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
3252 KB |
Output is correct |
2 |
Incorrect |
45 ms |
5864 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |