# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
227880 |
2020-04-29T06:31:16 Z |
kartel |
Zamjena (COCI18_zamjena) |
C++14 |
|
211 ms |
19072 KB |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
#define N +100500
#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
map <string, int> mk;
map <string, vector <string> > g;
int i, n, j, can, kl;
string a[N], b[N];
bool isdig(string s)
{
int i = 0;
while (i < s.size() && s[i] >= '0' && s[i] <= '9') i++;
return i == s.size();
}
void dfs(string v, string pr)
{
if (isdig(v)) kl++;
if (kl > 1) can = 0;
mk[v] = 1;
for (auto u : g[v])
{
if (u == pr || mk[u]) continue;
dfs(u, v);
}
}
int main()
{
srand(time(0));
ios_base::sync_with_stdio(0);
iostream::sync_with_stdio(0);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
// in("sum.in");
// out("output.txt");
cin >> n;
for (i = 1; i <= n; i++) cin >> a[i];
for (i = 1; i <= n; i++) cin >> b[i];
can = 1;
for (i = 1; i <= n; i++)
{
g[a[i]].pb(b[i]);
g[b[i]].pb(a[i]);
}
for (i = 1; i <= n; i++)
{
if (!mk[a[i]]) {kl = 0; dfs(a[i], "");}
if (!mk[b[i]]) {kl = 0; dfs(b[i], "");}
}
cout << (can == 1 ? "DA" : "NE");
}
// 119 78 175 411
Compilation message
zamjena.cpp: In function 'bool isdig(std::__cxx11::string)':
zamjena.cpp:32:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (i < s.size() && s[i] >= '0' && s[i] <= '9') i++;
~~^~~~~~~~~~
zamjena.cpp:33:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
return i == s.size();
~~^~~~~~~~~~~
# |
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 |
10 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 |
10 ms |
6888 KB |
Output is correct |
2 |
Correct |
11 ms |
6784 KB |
Output is correct |
3 |
Correct |
14 ms |
7296 KB |
Output is correct |
4 |
Correct |
15 ms |
7424 KB |
Output is correct |
5 |
Correct |
16 ms |
7424 KB |
Output is correct |
6 |
Correct |
16 ms |
7296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
8960 KB |
Output is correct |
2 |
Correct |
57 ms |
10872 KB |
Output is correct |
3 |
Correct |
99 ms |
13560 KB |
Output is correct |
4 |
Correct |
129 ms |
14968 KB |
Output is correct |
5 |
Correct |
211 ms |
19072 KB |
Output is correct |
6 |
Correct |
134 ms |
14972 KB |
Output is correct |