Submission #547679

# Submission time Handle Problem Language Result Execution time Memory
547679 2022-04-11T11:29:12 Z nishkarsh Vlak (COCI20_vlak) C++14
70 / 70
16 ms 10452 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
using namespace std;
ll powmod(ll base,ll exponent,ll mod){
	ll ans=1;
	if(base<0) base+=mod;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int INF = 2e9;
const ll INFLL = 4e18;
const int upperlimit = 1e5+10;
const int mod = 1e9+7;
const int letters = 26;
int to_int(char c){
	int ans = (c-'a');
	return ans;
}
int trie[upperlimit][letters];
int occ[upperlimit][2];
int node_cnt = 0;
void addstring(string s,int player){
	int node = 0;
	for(int i = 0; i < s.size(); i++){
		if(! trie[node][to_int(s[i])]) trie[node][to_int(s[i])] = ++node_cnt;
		node = trie[node][to_int(s[i])];
		occ[node][player]++;
	}
}
bool dfs(int node,int player){
	bool ans=false;
	for(int i = 0; i < letters; i++) if(trie[node][i]) if(occ[trie[node][i]][player]) ans|=(1^dfs(trie[node][i],1^player));
	return ans;
}
int main(){
	int n,m;
	string s;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> s;
		addstring(s,0);
	}
	cin >> m;
	for(int i = 1; i <= m; i++){
		cin >> s;
		addstring(s,1);
	}
	if(dfs(0,0)) cout << "Nina";
	else cout << "Emilija";
	return 0;
}

Compilation message

Main.cpp: In function 'void addstring(std::string, int)':
Main.cpp:50:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  for(int i = 0; i < s.size(); i++){
      |                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 424 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 9792 KB Output is correct
2 Correct 15 ms 9212 KB Output is correct
3 Correct 13 ms 8604 KB Output is correct
4 Correct 16 ms 9528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 9936 KB Output is correct
2 Correct 13 ms 10452 KB Output is correct
3 Correct 13 ms 9612 KB Output is correct
4 Correct 16 ms 9804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 9424 KB Output is correct
2 Correct 14 ms 9232 KB Output is correct
3 Correct 14 ms 9428 KB Output is correct
4 Correct 14 ms 10064 KB Output is correct