답안 #725063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725063 2023-04-16T16:16:29 Z Tsiannis Vlak (COCI20_vlak) C++14
0 / 70
370 ms 524292 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(int node, bool turn){
        if (!turn){
        for (char i='a';i<='z';i++){
            if (T1[node][i-'a']!=-1){
                return !solve(T2[node][i-'a'],1);
            }
        }
        return 0;
        }
        else{
            for (char i='a';i<='z';i++){
            if (T2[node][i-'a']!=-1){
                return !solve(T1[node][i-'a'],1);
            }
        }
        return 0;
        }
    }
    int main()
    {
        memset(T1,-1,sizeof(T1));
        memset(T2,-1,sizeof(T2));
        int n; cin>>n;
        ll next=1;
        while(n--){
                string s; cin>>s;
                int 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;
                int 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);
        if (ans)
            cout<<"Nina"<<endl;
        else    
            cout<<"Emilija"<<endl;
        return 0;
    }

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:36:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |                 while(i<s.size()){
      |                       ~^~~~~~~~~
Main.cpp:53:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |                 while(i<s.size()){
      |                       ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 370 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 332 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 335 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 334 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 365 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 334 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 314 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -