Submission #158932

#TimeUsernameProblemLanguageResultExecution timeMemory
158932aviroop123Zamjena (COCI18_zamjena)C++14
70 / 70
136 ms14388 KiB
#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 (stderr)

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;
                        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...