# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
721424 | 2023-04-10T21:26:44 Z | vjudge1 | Zamjena (COCI18_zamjena) | C++17 | 303 ms | 6904 KB |
#include <bits/stdc++.h> #define sts stable_sort #define B begin() #define rB rbegin() #define E end() #define rE rend() #define F first #define S second #define pb push_back #define ppb pop_back() #define pf push_front #define ppf pop_front() #define eb emplace_back #define ll long long #define ui unsigned int #define ull unsigned long long using namespace std; const int MAXN = 1e6 + 4; const int MOD = 1e9 + 7; map<string, ll> m; ll to_int(string s){ ll n = 0; for(ll i = 0; i < s.size(); i++){ n *= 10; n += s[i] - '0'; } return n; } bool comp(string s){ if(s[0] - '0' > 9){ return 1; } return 0; } bool f(vector<pair<string, string> > &v, ll &n){ for(ll i = 0; i < n; i++){ if(comp(v[i].S) && comp(v[i].F)){ if(m[v[i].F] == -1 && m[v[i].S] != -1){ m[v[i].F] = m[v[i].S]; }else if(m[v[i].S] == -1 && m[v[i].F] != -1){ m[v[i].S] = m[v[i].F]; }else if(m[v[i].S] != m[v[i].F]){ return 0; } }else if(!comp(v[i].S)){ if(m[v[i].F] != -1 && m[v[i].F] != to_int(v[i].S)){ return 0; } m[v[i].F] = to_int(v[i].S); }else if(!comp(v[i].F)){ if(m[v[i].S] != -1 && m[v[i].S] != to_int(v[i].F)){ return 0; } m[v[i].S] = to_int(v[i].F); }else if(v[i].S != v[i].F){ return 0; } } return 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; vector<pair<string, string> > v(n); for(ll i = 0; i < n; i++){ cin >> v[i].F; m[v[i].F] = -1; } for(ll i = 0; i < n; i++){ cin >> v[i].S; m[v[i].S] = -1; } f(v, n); f(v, n); f(v, n); bool a = f(v, n); if(a){ cout << "DA\n"; }else{ cout << "NE\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 340 KB | Output is correct |
2 | Correct | 3 ms | 424 KB | Output is correct |
3 | Correct | 6 ms | 664 KB | Output is correct |
4 | Correct | 7 ms | 724 KB | Output is correct |
5 | Correct | 10 ms | 724 KB | Output is correct |
6 | Correct | 9 ms | 596 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 1364 KB | Output is correct |
2 | Correct | 70 ms | 2592 KB | Output is correct |
3 | Correct | 105 ms | 3988 KB | Output is correct |
4 | Correct | 75 ms | 4884 KB | Output is correct |
5 | Correct | 303 ms | 6904 KB | Output is correct |
6 | Correct | 202 ms | 5048 KB | Output is correct |