# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
702139 | 2023-02-23T05:48:27 Z | chenyan | Zamjena (COCI18_zamjena) | C++17 | 84 ms | 7968 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define all(x) x.begin(),x.end() #define pb emplace_back #define N 50010 map<string,int>m; int a[2][N],cnt; bitset<N>vis; vector<int>g[N]; void dfs(int v){ vis[v]=1; if(v<=1000)cnt++; for(int u:g[v]){ if(vis[u])continue; dfs(u); } } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,k,i,j,t=0,u,v; string s; cin>>n; for(u=0;u<2;u++){ for(i=0;i<n;i++){ cin>>s; int x=0; if(s[0]>='0'&&s[0]<='9'){ for(j=1,k=0;k<s.size();j*=10,k++) x+=(s[s.size()-1-k]-'0')*j; a[u][i]=x; } else{ if(!m[s])m[s]=(++t)+1000; a[u][i]=m[s]; } } } for(i=0;i<n;i++)g[a[0][i]].pb(a[1][i]),g[a[1][i]].pb(a[0][i]); for(i=1;i<=1000;i++){ cnt=0; dfs(i); if(cnt>1){ cout<<"NE\n"; return 0; } } cout<<"DA\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1492 KB | Output is correct |
2 | Correct | 1 ms | 1492 KB | Output is correct |
3 | Correct | 1 ms | 1444 KB | Output is correct |
4 | Correct | 1 ms | 1620 KB | Output is correct |
5 | Correct | 1 ms | 1492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1492 KB | Output is correct |
2 | Correct | 1 ms | 1504 KB | Output is correct |
3 | Correct | 1 ms | 1492 KB | Output is correct |
4 | Correct | 1 ms | 1496 KB | Output is correct |
5 | Correct | 1 ms | 1492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1492 KB | Output is correct |
2 | Correct | 1 ms | 1448 KB | Output is correct |
3 | Correct | 1 ms | 1496 KB | Output is correct |
4 | Correct | 2 ms | 1500 KB | Output is correct |
5 | Correct | 1 ms | 1500 KB | Output is correct |
6 | Correct | 2 ms | 1492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1620 KB | Output is correct |
2 | Correct | 3 ms | 1504 KB | Output is correct |
3 | Correct | 3 ms | 1748 KB | Output is correct |
4 | Correct | 4 ms | 1876 KB | Output is correct |
5 | Correct | 4 ms | 1876 KB | Output is correct |
6 | Correct | 4 ms | 1748 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 2524 KB | Output is correct |
2 | Correct | 25 ms | 3636 KB | Output is correct |
3 | Correct | 38 ms | 5028 KB | Output is correct |
4 | Correct | 45 ms | 5640 KB | Output is correct |
5 | Correct | 84 ms | 7968 KB | Output is correct |
6 | Correct | 54 ms | 5752 KB | Output is correct |