Submission #1279347

#TimeUsernameProblemLanguageResultExecution timeMemory
1279347escobrandSelling RNA Strands (JOI16_selling_rna)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;
#define fi first
#define se second
#define ll long long
#define all(v) v.begin(),v.end()
#define mk make_pair
#define pb push_back
#define eb emplace_back
typedef pair<int,int> pii;

int id[300];

const int maxn = 1e5 + 10;
int t;
bitset<maxn> bit[maxn*2];

struct Trie
{
  struct Node
  {
    int child[4];
    int idx;
    vector<int> v;
    
    Node()
    {
      idx = 0;
      for(int i = 0;i<4;i++)child[i] = -1;
    }
  };
  vector<Node> nodes;
  
  int create()
  {
    nodes.eb();
    return nodes.size()-1;
  }
  
  Trie()
  {
    create();
  }
  
  void add(string &s ,int idx)
  {
    int pos = 0;
    for(char ch : s)
    {
      int c = id[ch];
      if(nodes[pos].child[c]==-1)nodes[pos].child[c] = create();
      pos = nodes[pos].child[c];
      nodes[pos].v.eb(idx);
    }
    
  }
  
  int cal(string &s)
  {
    int pos = 0;
    for(char ch : s)
    {
      int c = id[ch];
      if(nodes[pos].child[c]==-1)return 0;
      pos = nodes[pos].child[c];
    }
    if(nodes[pos].idx==0)
    {
      nodes[pos].idx = ++t;
      for(const int & k : nodes[pos].v) bit[t].set(k);
    }
    return nodes[pos].idx;
  }
}pre,suf;

int n,m;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    id['A'] = 0;
    id['U'] = 1;
    id['G'] = 2;
    id['C'] = 3;
    cin>>n>>m;
    for(int i = 0;i<n;i++)
    {
      string s;
      cin>>s;
      pre.add(s,i);
      reverse(all(s));
      suf.add(s,i);
    }
    
    while(m--)
    {
      string p,s;
      cin>>p>>s;
      int i = pre.cal(p);
      int j = suf.cal(s);
      if(i&&j)
      {
        cout<<(bit[i]&bit[j]).count()<<'\n';
      }
      else cout<<0<<'\n';
    }
    
    return 0;
}

Compilation message (stderr)

/tmp/ccTcjhcT.o: in function `Trie::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, int) [clone .isra.0]':
selling_rna.cpp:(.text+0x24): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/ccTcjhcT.o
selling_rna.cpp:(.text+0x1c3): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/ccTcjhcT.o
selling_rna.cpp:(.text+0x218): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/ccTcjhcT.o
selling_rna.cpp:(.text+0x257): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/ccTcjhcT.o
/tmp/ccTcjhcT.o: in function `main':
selling_rna.cpp:(.text.startup+0x5d): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
selling_rna.cpp:(.text.startup+0x64): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
selling_rna.cpp:(.text.startup+0x6e): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/ccTcjhcT.o
selling_rna.cpp:(.text.startup+0x78): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/ccTcjhcT.o
selling_rna.cpp:(.text.startup+0x82): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/ccTcjhcT.o
selling_rna.cpp:(.text.startup+0x8c): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/ccTcjhcT.o
selling_rna.cpp:(.text.startup+0xde): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1f): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1ed): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x252): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2bc): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x316): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x50f): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x57d): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5f0): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x654): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status