Submission #371288

# Submission time Handle Problem Language Result Execution time Memory
371288 2021-02-26T11:55:20 Z uacoder123 Type Printer (IOI08_printer) C++14
0 / 100
38 ms 22380 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) lli(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <ii,lli> iii;
typedef vector <lli> vi;
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
vi al[25000*26];
int dp[25000*26],dp1[25000*26],id[25000*26],n,c=1;
string s;
void ad(int node,int cur)
{
  if(cur==s.size())
    return;
  for(int i=0;i<al[node].size();++i)
  {
    if(id[al[node][i]]==s[cur]-'a')
      return ad(al[node][i],cur+1);
  }
  al[node].pb(c);
  id[c]=s[cur]-'a';
  c++;
  return ad(c-1,cur+1);
}
void dfs(int node)
{
  for(int i=0;i<al[node].size();++i)
    dfs(al[node][i]);
  int m=0;
  dp[node]=2;
  dp1[node]=1;
  for(int i=0;i<al[node].size();++i)
  {
    dp[node]+=dp[al[node][i]];
    dp1[node]+=dp[al[node][i]];
    m=min(m,-dp[al[node][i]]+dp1[al[node][i]]);
  }
  dp1[node]+=m;
  if(al[node].size()==0)
  {
    dp[node]=3;
    dp1[node]=2;
  }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin>>n;
  for(int i=0;i<n;++i)
  {
    cin>>s;
    ad(0,0);
  }
  dfs(0);
  cout<<dp1[0]-1<<endl;
  return 0;
} 

Compilation message

printer.cpp: In function 'void ad(int, int)':
printer.cpp:24:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   if(cur==s.size())
      |      ~~~^~~~~~~~~~
printer.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int i=0;i<al[node].size();++i)
      |               ~^~~~~~~~~~~~~~~~
printer.cpp: In function 'void dfs(int)':
printer.cpp:38:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for(int i=0;i<al[node].size();++i)
      |               ~^~~~~~~~~~~~~~~~
printer.cpp:43:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int i=0;i<al[node].size();++i)
      |               ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 15596 KB Line "" doesn't correspond to pattern "[a-z\-P]{1}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 15616 KB Line "" doesn't correspond to pattern "[a-z\-P]{1}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 15596 KB Line "" doesn't correspond to pattern "[a-z\-P]{1}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 15596 KB Line "" doesn't correspond to pattern "[a-z\-P]{1}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 15596 KB Line "" doesn't correspond to pattern "[a-z\-P]{1}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 15852 KB Line "" doesn't correspond to pattern "[a-z\-P]{1}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 16620 KB Line "" doesn't correspond to pattern "[a-z\-P]{1}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 18312 KB Line "" doesn't correspond to pattern "[a-z\-P]{1}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 22380 KB Line "" doesn't correspond to pattern "[a-z\-P]{1}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 20716 KB Line "" doesn't correspond to pattern "[a-z\-P]{1}"
2 Halted 0 ms 0 KB -