# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
983371 | 2024-05-15T11:34:16 Z | roctes7 | Vlak (COCI20_vlak) | C++17 | 13 ms | 38488 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); const double eps = 1e-6; const int MAX = 3e5+3; int adj[MAX][30]; int num[2][MAX]; int nex = 1; int n; void init(){ memset(adj,-1,sizeof adj); } void add(string s,int turn){ int i = 0, v = 0; while(i < s.size()){ if(adj[v][s[i]-'a'] == -1) v = adj[v][s[i++]-'a'] = nex++; else v = adj[v][s[i++]-'a']; } num[turn][v]++; } void dfs(int x){ for(char c='a';c<='z';c++){ if(adj[x][c-'a']!=-1){ dfs(adj[x][c-'a']); num[0][x]+=num[0][adj[x][c-'a']]; num[1][x]+=num[1][adj[x][c-'a']]; } } } bool dp(int x,int turn){ bool res = false; for(char c='a';c<='z';c++)if(adj[x][c-'a']!=-1){ if(num[turn][adj[x][c-'a']]>0){ res |= (!(dp(adj[x][c-'a'],(turn+1)%2))); } } return res; } int main(){ fastio; //freopen("output.txt","w",stdout); init(); int n; cin>>n; for(int i=0;i<n;i++){ string s; cin>>s; add(s,0); } int m; cin>>m; for(int i=0;i<m;i++){ string s; cin>>s; add(s,1); } dfs(0); cout<<(dp(0,0)?"Nina":"Emilija")<<endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 37892 KB | Output is correct |
2 | Correct | 6 ms | 37724 KB | Output is correct |
3 | Correct | 5 ms | 37724 KB | Output is correct |
4 | Correct | 6 ms | 37724 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 37724 KB | Output is correct |
2 | Correct | 5 ms | 37724 KB | Output is correct |
3 | Correct | 5 ms | 37724 KB | Output is correct |
4 | Correct | 5 ms | 37724 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 37724 KB | Output is correct |
2 | Correct | 5 ms | 37724 KB | Output is correct |
3 | Correct | 6 ms | 37724 KB | Output is correct |
4 | Correct | 6 ms | 37620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 37724 KB | Output is correct |
2 | Correct | 5 ms | 37724 KB | Output is correct |
3 | Correct | 7 ms | 37980 KB | Output is correct |
4 | Correct | 5 ms | 37724 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 38236 KB | Output is correct |
2 | Correct | 13 ms | 38236 KB | Output is correct |
3 | Correct | 12 ms | 38236 KB | Output is correct |
4 | Correct | 13 ms | 38236 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 37980 KB | Output is correct |
2 | Correct | 12 ms | 37980 KB | Output is correct |
3 | Correct | 11 ms | 38488 KB | Output is correct |
4 | Correct | 12 ms | 38232 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 38232 KB | Output is correct |
2 | Correct | 12 ms | 38236 KB | Output is correct |
3 | Correct | 12 ms | 38236 KB | Output is correct |
4 | Correct | 12 ms | 38124 KB | Output is correct |