Submission #1290110

#TimeUsernameProblemLanguageResultExecution timeMemory
1290110Faisal_SaqibType Printer (IOI08_printer)C++20
Compilation error
0 ms0 KiB
/* VENI VIDI VICI */ #ifdef ONLINE_JUDGE #include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); using i128 = __int128; using ll = long long; using ull = unsigned long long; using ld = long double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vpi = vector<pair<int, int>>; using vvi = vector<vi>; using sll = set<ll>; template<class T> istream& operator>>(istream& is, vector<T>& v) { for(auto &i:v) is>>i; return is; } template<class T1,class T2> istream& operator>>(istream& is, pair<T1,T2>& p) { is>>p.fi>>p.se; return is; } template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { for(const auto &i:v) os<<i<<' '; return os; } template<class T1,class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& p) { os<<p.fi<<' '<<p.se; return os; } void pyn(bool x) { cout<<(x?"YES":"NO")<<endl; } void pYN(bool x) { cout<<(x?"Yes":"No")<<endl; } void pAB(bool x) { cout<<(x?"Alice":"Bob")<<endl; } ll powmod(ll a,ll b,ll modulo) { if(b==0){ return 1; } ll temp=powmod(a,b/2,modulo); if(b%2==0){ return (temp*temp)%modulo; } else{ return (a*((temp*temp)%modulo))%modulo; } } bool Prime(ll n){ for (ll i = 2; i*i <= n; i++) if (n % i == 0) return false; return (n>1); } void readIO() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); } #endif void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); readIO(); int uwu=1; // cin>>uwu; for(int tc=1;tc<=uwu;tc++) { // cout<<"Case #"<<tc<<": "; solve(); } return 0; } const int N=1e6+100; int nxt[N][26],lst=0,h[N]; bool ed[N]; void add(string s) { // cout<<"insert "<<s<<endl; int rt=0; for(int i=0;i<s.size();i++) { int j=s[i]-'a'; if(nxt[rt][j]==0) { nxt[rt][j]=++lst; } // cout<<rt<<' '; rt=nxt[rt][j]; h[rt]=max(h[rt],(int)s.size()-i); } ed[rt]=1; // cout<<rt<<endl; } vector<char> ans; void print(int rt,bool keep) { // cout<<"At "<<rt<<endl; if(ed[rt]) { // cout<<'P'<<endl; ans.pb(char('P')); } int mx=0,v=-1; for(int j=0;j<26;j++) { if(h[nxt[rt][j]]>mx and nxt[rt][j]!=0) { mx=h[nxt[rt][j]]; v=j; } } if(v==-1)return; // cout<<"At "<<rt<<' '<<keep<<' '<<mx<<' '<<v<<endl; for(int j=0;j<26;j++) { if(h[nxt[rt][j]]>0 and nxt[rt][j]!=0 and j!=v) { // cout<<char('a'+j)<<endl; ans.pb(char('a'+j)); print(nxt[rt][j],0); ans.pb('-'); // cout<<'-'<<endl; } } ans.pb(char('a'+v)); // cout<<char('a'+v)<<endl; print(nxt[rt][v],keep); if(!keep) { ans.pb('-'); // cout<<'-'<<endl; } } void solve() { int n; cin>>n; int len=0,mx=0; for(int i=0;i<n;i++) { string s; cin>>s; len+=2*s.size()+1; mx=max(mx,(int)s.size()); // cout<<"cur "<<s<<endl; add(s); } print(0,1); cout<<ans.size()<<endl; for(auto x:ans)cout<<x<<endl; }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:88:5: error: 'ios' has not been declared
   88 |     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      |     ^~~
printer.cpp:88:30: error: 'cin' was not declared in this scope
   88 |     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      |                              ^~~
printer.cpp:88:42: error: 'cout' was not declared in this scope
   88 |     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      |                                          ^~~~
printer.cpp:90:5: error: 'readIO' was not declared in this scope
   90 |     readIO();
      |     ^~~~~~
printer.cpp: At global scope:
printer.cpp:105:6: error: variable or field 'add' declared void
  105 | void add(string s)
      |      ^~~
printer.cpp:105:10: error: 'string' was not declared in this scope
  105 | void add(string s)
      |          ^~~~~~
printer.cpp:123:1: error: 'vector' does not name a type
  123 | vector<char> ans;
      | ^~~~~~
printer.cpp: In function 'void print(int, bool)':
printer.cpp:130:9: error: 'ans' was not declared in this scope
  130 |         ans.pb(char('P'));
      |         ^~~
printer.cpp:149:13: error: 'ans' was not declared in this scope
  149 |             ans.pb(char('a'+j));
      |             ^~~
printer.cpp:155:5: error: 'ans' was not declared in this scope
  155 |     ans.pb(char('a'+v));
      |     ^~~
printer.cpp: In function 'void solve()':
printer.cpp:167:5: error: 'cin' was not declared in this scope
  167 |     cin>>n;
      |     ^~~
printer.cpp:171:9: error: 'string' was not declared in this scope
  171 |         string s;
      |         ^~~~~~
printer.cpp:172:14: error: 's' was not declared in this scope
  172 |         cin>>s;
      |              ^
printer.cpp:174:12: error: 'max' was not declared in this scope; did you mean 'mx'?
  174 |         mx=max(mx,(int)s.size());
      |            ^~~
      |            mx
printer.cpp:176:9: error: 'add' was not declared in this scope
  176 |         add(s);
      |         ^~~
printer.cpp:179:5: error: 'cout' was not declared in this scope
  179 |     cout<<ans.size()<<endl;
      |     ^~~~
printer.cpp:179:11: error: 'ans' was not declared in this scope
  179 |     cout<<ans.size()<<endl;
      |           ^~~
printer.cpp:179:23: error: 'endl' was not declared in this scope; did you mean 'ed'?
  179 |     cout<<ans.size()<<endl;
      |                       ^~~~
      |                       ed