Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
codechef
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#include<bits/stdc++.h> using namespace std; #define mem(A) memset(A,0,sizeof(A)) #define loop(i,a,n) for(i=a;i<n;i++) #define pb push_back #define mkp make_pair typedef long long ll; struct *tri{ tri *child[26]; bool END; }; tri *getnode() { ll i; tri *p=new tri; p->END=false; loop(i,0,26) p->child[i]=NULL; return p; } void ins(tri *root,string s) { ll i; tri *p=root; loop(i,0,s.length()) { if(!p->child[s[i]-'a']) p->child[s[i]-'a']=getnode(); p=p->child[s[i]-'a']; } p->END=true; } void che(tri *root,sting s) { ll i; tri *p=root; loop(i,0,s.length()) { ll index=s[i]-'a'; if(p->child[index]) { ans= } } } int main() { //freopen("input.txt", "r", stdin); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); tri *root=new root; root=getnode(); cin>>n; loop(i,0,n) { cin>>s; S.insert(s); ins(root,s); } cin>>q; while(q--) { cin>>x>>s; che(root,s); } }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
edit mode
|
history
|
discussion