#include "bits/stdc++.h"
using namespace std;
#define pb push_back
// #define int long long
typedef long long ll;
#define fi first
#define se second
#define pii pair<int,int>
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(s) (int)s.size()
#define y1 fdfbvfds
typedef long double f80;
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l,ll r){
uniform_int_distribution<ll> uid(l, r);
return uid(rng);
}
const int mod = 1e9 + 7;
int pwr(int a,ll b) {
int ans = 1;
while(b) {
if(b & 1) {
ans = ((ll)ans * a) % mod;
}
a = ((ll)a * a) % mod;
b >>= 1;
}
return ans;
}
const int N = 1e5 + 5;
vector<int> g[N];
string a[N], b[N];
map<string,int> m;
bool vis[N];
void dfs(int u) {
vis[u] = 1;
for(int v : g[u]) {
if(!vis[v]) {
dfs(v);
}
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
fr(i, 1, n) {
cin >> a[i];
m[a[i]] = 0;
}
fr(i, 1, n) {
cin >> b[i];
m[b[i]] = 0;
}
int cc = 1000;
for(auto &it : m) {
it.se = ++cc;
}
fr(i, 1, n) {
int x1 = 0, x2 = 0;
bool dec1 = 0, dec2 = 0;
if(a[i][0] >= '0' && a[i][0] <= '9') {
dec1 = 1;
x1 = stoi(a[i]);
}
else {
x1 = m[a[i]];
}
if(b[i][0] >= '0' && b[i][0] <= '9') {
dec2 = 1;
x2 = stoi(b[i]);
}
else {
x2 = m[b[i]];
}
g[x1].pb(x2);
g[x2].pb(x1);
}
fr(i, 0, 1000) {
if(!vis[i]) {
dfs(i);
}
else {
cout << "NE";
return 0;
}
}
cout << "DA" << endl;
return 0;
}
Compilation message
zamjena.cpp: In function 'int main()':
zamjena.cpp:72:14: warning: variable 'dec1' set but not used [-Wunused-but-set-variable]
bool dec1 = 0, dec2 = 0;
^~~~
zamjena.cpp:72:24: warning: variable 'dec2' set but not used [-Wunused-but-set-variable]
bool dec1 = 0, dec2 = 0;
^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
8952 KB |
Output is correct |
2 |
Correct |
9 ms |
8952 KB |
Output is correct |
3 |
Correct |
9 ms |
8952 KB |
Output is correct |
4 |
Correct |
9 ms |
8952 KB |
Output is correct |
5 |
Correct |
9 ms |
8952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
8952 KB |
Output is correct |
2 |
Correct |
9 ms |
8952 KB |
Output is correct |
3 |
Correct |
9 ms |
8952 KB |
Output is correct |
4 |
Correct |
9 ms |
8952 KB |
Output is correct |
5 |
Correct |
9 ms |
8952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
8952 KB |
Output is correct |
2 |
Correct |
9 ms |
8952 KB |
Output is correct |
3 |
Correct |
9 ms |
8952 KB |
Output is correct |
4 |
Correct |
10 ms |
8952 KB |
Output is correct |
5 |
Correct |
9 ms |
9080 KB |
Output is correct |
6 |
Correct |
9 ms |
8952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
9080 KB |
Output is correct |
2 |
Correct |
10 ms |
8952 KB |
Output is correct |
3 |
Correct |
13 ms |
9208 KB |
Output is correct |
4 |
Correct |
14 ms |
9336 KB |
Output is correct |
5 |
Correct |
14 ms |
9236 KB |
Output is correct |
6 |
Correct |
14 ms |
9208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
9720 KB |
Output is correct |
2 |
Correct |
44 ms |
10536 KB |
Output is correct |
3 |
Correct |
70 ms |
11896 KB |
Output is correct |
4 |
Correct |
88 ms |
12408 KB |
Output is correct |
5 |
Correct |
136 ms |
14388 KB |
Output is correct |
6 |
Correct |
100 ms |
11996 KB |
Output is correct |