Submission #226116

# Submission time Handle Problem Language Result Execution time Memory
226116 2020-04-22T15:21:33 Z inluminas Type Printer (IOI08_printer) C++14
0 / 100
680 ms 18040 KB
#include<bits/stdc++.h>
using namespace std;
const int lmt=1e6;
int adj[lmt][26];
int root[lmt];
int indx=1;
bool vis[lmt];
int cnt=0;
void insert(string s,int now)
{
    for(char c:s)
    {
        c-='a';
        if(!adj[now][c])
        {
            indx++;
            root[indx]=now;
            adj[now][c]=indx;
            now=indx;
            //cross[now]++;
        }
        else
        {
            now=adj[now][c];
            //cross[now]++;
        }
    }
}
void dfs(int u)
{
    if(vis[u]==0)
    {
        cnt++;
        vis[u]=1;
    }
    bool on=1;
    for(int i=0;i<26;i++)
    {
        if(adj[u][i]!=0)
        {
            on=0;
            char c='a'+i;
            cout<<c<<endl;
            dfs(adj[u][i]);
        }
    }
    if(on) cout<<'P'<<endl;
    if(cnt<indx) cout<<'-'<<endl;
}
int main()
{
    //#ifndef ONLINE_JUDGE
    //    freopen("take.in","r",stdin);
    //    freopen("give.out","w",stdout);
    //#endif
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        insert(s,1);
    }
    dfs(1);
}

Compilation message

printer.cpp: In function 'void insert(std::__cxx11::string, int)':
printer.cpp:14:23: warning: array subscript has type 'char' [-Wchar-subscripts]
         if(!adj[now][c])
                       ^
printer.cpp:18:23: warning: array subscript has type 'char' [-Wchar-subscripts]
             adj[now][c]=indx;
                       ^
printer.cpp:24:27: warning: array subscript has type 'char' [-Wchar-subscripts]
             now=adj[now][c];
                           ^
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Expected integer, but "t" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Expected integer, but "e" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Expected integer, but "h" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Expected integer, but "b" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 384 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1152 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 115 ms 3072 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 279 ms 7496 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 680 ms 18040 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 550 ms 14200 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -