# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
464634 | 2021-08-13T14:47:52 Z | aihay | Zamjena (COCI18_zamjena) | C++14 | 266 ms | 44208 KB |
#pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize("-Ofast") #include <bits/stdc++.h> using namespace std; typedef int in; #define int long long #define f first #define s second #define pb push_back #define pp push #define double long double #define ceil(x,y) (x/y)+(x%y!=0)*((double)(1.0*x/y)<0?0:1) #define floor(x,y) (x/y)+(x%y!=0)*((double)(1.0a*x/y)<0?-1:0) const int MAX=1e7; const int MOD=1e9+7; const int MAAX=1e18; string arr[500010],arr2[500010]; map<string,vector<string> >mp; map<string,int> vis; set<string> fun(string idx){ set<string> ans; if(vis[idx]) return ans; vis[idx]=1; for(int i=0;i<mp[idx].size()&&ans.size()<2;i++){ set<string>x=fun(mp[idx][i]); set<string>::iterator it; for(it=x.begin();it!=x.end()&&ans.size()<2;it++){ ans.insert(*it); } } if(idx[0]>='0'&&idx[0]<='9') ans.insert(idx); return ans; } in main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int tc=1; //cin>>tc; while(tc--){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>arr[i]; } for(int i=0;i<n;i++){ string s; cin>>s; arr2[i]=s; mp[arr[i]].pb(s); mp[s].pb(arr[i]); } bool bol=1; for(int i=0;i<n;i++){ bol&=(fun(arr[i]).size()>1?0:1); bol&=(fun(arr2[i]).size()>1?0:1); } cout<<(bol?"DA\n":"NE\n"); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 31628 KB | Output is correct |
2 | Correct | 22 ms | 31548 KB | Output is correct |
3 | Correct | 22 ms | 31612 KB | Output is correct |
4 | Correct | 22 ms | 31564 KB | Output is correct |
5 | Correct | 24 ms | 31556 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 31568 KB | Output is correct |
2 | Correct | 20 ms | 31624 KB | Output is correct |
3 | Correct | 21 ms | 31596 KB | Output is correct |
4 | Correct | 20 ms | 31628 KB | Output is correct |
5 | Correct | 22 ms | 31564 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 31564 KB | Output is correct |
2 | Correct | 21 ms | 31564 KB | Output is correct |
3 | Correct | 22 ms | 31564 KB | Output is correct |
4 | Correct | 21 ms | 31564 KB | Output is correct |
5 | Correct | 22 ms | 31580 KB | Output is correct |
6 | Correct | 25 ms | 31556 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 31872 KB | Output is correct |
2 | Correct | 34 ms | 31756 KB | Output is correct |
3 | Correct | 27 ms | 32276 KB | Output is correct |
4 | Correct | 36 ms | 32356 KB | Output is correct |
5 | Correct | 27 ms | 32400 KB | Output is correct |
6 | Correct | 30 ms | 32204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 33892 KB | Output is correct |
2 | Correct | 80 ms | 35760 KB | Output is correct |
3 | Correct | 135 ms | 38716 KB | Output is correct |
4 | Correct | 167 ms | 40220 KB | Output is correct |
5 | Correct | 266 ms | 44208 KB | Output is correct |
6 | Correct | 206 ms | 40260 KB | Output is correct |