# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
227876 |
2020-04-29T06:25:10 Z |
NONAME |
Zamjena (COCI18_zamjena) |
C++17 |
|
498 ms |
22060 KB |
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define ft first
#define sd second
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
using namespace std;
typedef long long ll;
typedef long double ld;
int n, m;
bool mk[N];
string s[N], t[N];
set <string> se;
map <string, string> val;
vector <string> ord;
map <string, vector <pair <string, int> > > g;
void dfs(string v, int p) {
if (mk[p])
return;
mk[p] = 1;
ord.pb(v);
if (v[0] >= '0' && v[0] <= '9')
se.insert(v);
for (int i = 0; i < sz(g[v]); i++)
dfs(g[v][i].ft, g[v][i].sd);
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// in("input.txt");
cin >> n;
for (int i = 0; i < n; i++)
cin >> s[i], val[s[i]] = "-1";
for (int i = 0; i < n; i++)
cin >> t[i], val[t[i]] = "-1";
for (int i = 0; i < n; i++) {
g[s[i]].pb({t[i], n + i});
g[t[i]].pb({s[i], i});
}
for (int i = 0; i < n; i++) {
ord.clear();
se.clear();
dfs(s[i], i);
dfs(t[i], n + i);
if (sz(se) > 1) {
cout << "NE";
return 0;
}
string c = "";
if (se.empty()) c = "1";
else c = *se.begin();
while (!ord.empty()) {
if (val[ord.back()] != "-1" && val[ord.back()] != c) {
cout << "NE";
return 0;
}
val[ord.back()] = c;
ord.ppb();
}
}
cout << "DA";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
6656 KB |
Output is correct |
2 |
Correct |
8 ms |
6656 KB |
Output is correct |
3 |
Correct |
8 ms |
6656 KB |
Output is correct |
4 |
Correct |
8 ms |
6656 KB |
Output is correct |
5 |
Correct |
8 ms |
6656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
6656 KB |
Output is correct |
2 |
Correct |
8 ms |
6656 KB |
Output is correct |
3 |
Correct |
8 ms |
6656 KB |
Output is correct |
4 |
Correct |
8 ms |
6656 KB |
Output is correct |
5 |
Correct |
8 ms |
6656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
6656 KB |
Output is correct |
2 |
Correct |
8 ms |
6656 KB |
Output is correct |
3 |
Correct |
8 ms |
6656 KB |
Output is correct |
4 |
Correct |
8 ms |
6656 KB |
Output is correct |
5 |
Correct |
8 ms |
6656 KB |
Output is correct |
6 |
Correct |
8 ms |
6656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
7296 KB |
Output is correct |
2 |
Correct |
13 ms |
6912 KB |
Output is correct |
3 |
Correct |
17 ms |
7424 KB |
Output is correct |
4 |
Correct |
21 ms |
7680 KB |
Output is correct |
5 |
Correct |
27 ms |
7552 KB |
Output is correct |
6 |
Correct |
33 ms |
7424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
10740 KB |
Output is correct |
2 |
Correct |
154 ms |
11896 KB |
Output is correct |
3 |
Correct |
110 ms |
15224 KB |
Output is correct |
4 |
Correct |
232 ms |
17016 KB |
Output is correct |
5 |
Correct |
498 ms |
22060 KB |
Output is correct |
6 |
Correct |
483 ms |
17656 KB |
Output is correct |