# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
472230 |
2021-09-13T09:55:01 Z |
_L__ |
Zamjena (COCI18_zamjena) |
C++17 |
|
145 ms |
18544 KB |
// This code is written by _L__
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define F_word ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7, N = 1e5+30, INF = 1e18;
const ld E = 1e-6;
bool an_int(string s){
return (s[0] >= '1' && s[0] <= '9');
}
bool a_word(string s){
return (s[0] >= 'a' && s[0] <= 'z');
}
vector<int> G[N+4];bool vis[N+3];int n; set<int> st;
vector<string> v(N+3), x(N+5);
void dfs(int node){
if(vis[node]) return;
vis[node] = 1;
if(node>n && an_int(x[node-n])){
ll c = 0;
for(auto b: x[node-n]){c*=10;c+=(b-'0');}
st.insert(c);
} else if(an_int(v[node])){
ll c = 0;
for(auto b: v[node]){c*=10;c+=(b-'0');}
st.insert(c);
}
for(auto i: G[node]){
if(!vis[i]) dfs(i);
}
}
int main(void){
F_word;
cin >> n;
map<string, vector<int>> mp;
for(int i = 1; i <= n; ++i){
cin >> v[i]; mp[v[i]].push_back(i);
}
for(int i = 1; i <= n; ++i){
cin >> x[i]; mp[x[i]].push_back(n+i);
}
for(int i = 1; i <= n; ++i){
G[i].push_back(n+i);
if(an_int(v[i])) continue;
for(auto c: mp[v[i]]){
if(c == i) continue;
G[i].push_back(c);
}
}
for(int i = 1; i <= n; ++i){
G[n+i].push_back(i);
if(an_int(x[i])) continue;
for(auto c: mp[x[i]]){
if(c == n+i) continue;
G[n+i].push_back(c);
}
}
bool y = 1;
for(int i = 1; i <= 2*n; ++i){
if(!(vis[i])){
st.clear();
dfs(i);
if(st.size() >= 2){y=0;break;}
}
}
cout << (y? "DA\n": "NE\n");
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8948 KB |
Output is correct |
2 |
Correct |
5 ms |
8952 KB |
Output is correct |
3 |
Correct |
5 ms |
8900 KB |
Output is correct |
4 |
Correct |
5 ms |
8952 KB |
Output is correct |
5 |
Correct |
5 ms |
8828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
8952 KB |
Output is correct |
2 |
Correct |
5 ms |
8908 KB |
Output is correct |
3 |
Correct |
5 ms |
8952 KB |
Output is correct |
4 |
Correct |
5 ms |
8880 KB |
Output is correct |
5 |
Correct |
5 ms |
8908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8952 KB |
Output is correct |
2 |
Correct |
5 ms |
8956 KB |
Output is correct |
3 |
Correct |
5 ms |
8908 KB |
Output is correct |
4 |
Incorrect |
6 ms |
8852 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
9204 KB |
Output is correct |
2 |
Correct |
7 ms |
9036 KB |
Output is correct |
3 |
Correct |
10 ms |
9420 KB |
Output is correct |
4 |
Correct |
11 ms |
9456 KB |
Output is correct |
5 |
Correct |
11 ms |
9432 KB |
Output is correct |
6 |
Correct |
11 ms |
9420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
11304 KB |
Output is correct |
2 |
Correct |
45 ms |
12316 KB |
Output is correct |
3 |
Correct |
67 ms |
14404 KB |
Output is correct |
4 |
Correct |
87 ms |
15484 KB |
Output is correct |
5 |
Correct |
145 ms |
18544 KB |
Output is correct |
6 |
Correct |
131 ms |
16604 KB |
Output is correct |