Submission #725064

# Submission time Handle Problem Language Result Execution time Memory
725064 2023-04-16T16:54:24 Z Tsiannis Vlak (COCI20_vlak) C++17
70 / 70
54 ms 88160 KB
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define INF 100000000007
    #define maxn 200005
    #define maxm 28
    ll T1[maxn][maxm];
    ll T2[maxn][maxm];
    bool solve(ll nodeN, ll nodeE, bool turn){
        if (turn==1&&nodeE==-1)
            return 0;
        if (turn==0&&nodeN==-1)
            return 0;
        if (!turn){
            bool maxi=0;
            for (char i='a';i<='z';i++){
                if (T1[nodeN][i-'a']!=-1){
                    maxi=max(maxi,!solve(T1[nodeN][i-'a'],T2[nodeE][i-'a'],1));
                }
            }
            return maxi;
        }
        else{
            bool maxi=0;
            for (char i='a';i<='z';i++){
                if (T2[nodeE][i-'a']!=-1){
                     maxi=max(maxi,!solve(T1[nodeN][i-'a'],T2[nodeE][i-'a'],0));
                }
            }
            return maxi;
        }
    }
    int main()
    {
        memset(T1,-1,sizeof(T1));
        memset(T2,-1,sizeof(T2));
        ll n; cin>>n;
        ll next=1;
        while(n--){
                string s; cin>>s;
                ll i=0,v=0;
                while(i<s.size()){
                    if (T1[v][s[i]-'a']==-1){
                        T1[v][s[i]-'a']=next;
                        v=next;
                        next++;
                    }
                    else
                    {
                        v=T1[v][s[i]-'a'];
                    }
                    ++i;
                }
        }
        next=1; cin>>n;
        while(n--){
                string s; cin>>s;
                ll i=0,v=0;
                while(i<s.size()){
                    if (T2[v][s[i]-'a']==-1){
                        T2[v][s[i]-'a']=next;
                        v=next;
                        next++;
                    }
                    else
                    {
                        v=T2[v][s[i]-'a'];
                    }
                    ++i;
                }
        }
        bool ans=solve(0,0,0);
        if (ans)
            cout<<"Nina"<<endl;
        else    
            cout<<"Emilija"<<endl;
        return 0;
    }

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:42:24: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |                 while(i<s.size()){
      |                       ~^~~~~~~~~
Main.cpp:59:24: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |                 while(i<s.size()){
      |                       ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 36 ms 87924 KB Output is correct
2 Correct 36 ms 87864 KB Output is correct
3 Correct 37 ms 87960 KB Output is correct
4 Correct 37 ms 87916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 87948 KB Output is correct
2 Correct 43 ms 87892 KB Output is correct
3 Correct 35 ms 87884 KB Output is correct
4 Correct 35 ms 87940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 87884 KB Output is correct
2 Correct 35 ms 87944 KB Output is correct
3 Correct 37 ms 87844 KB Output is correct
4 Correct 34 ms 87884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 87852 KB Output is correct
2 Correct 35 ms 87856 KB Output is correct
3 Correct 40 ms 88000 KB Output is correct
4 Correct 36 ms 87872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 88160 KB Output is correct
2 Correct 44 ms 88124 KB Output is correct
3 Correct 45 ms 88152 KB Output is correct
4 Correct 54 ms 88132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 88148 KB Output is correct
2 Correct 45 ms 88140 KB Output is correct
3 Correct 46 ms 88096 KB Output is correct
4 Correct 44 ms 88136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 88124 KB Output is correct
2 Correct 43 ms 88112 KB Output is correct
3 Correct 45 ms 88056 KB Output is correct
4 Correct 45 ms 88140 KB Output is correct