Submission #339399

#TimeUsernameProblemLanguageResultExecution timeMemory
339399ijxjdjdSelling RNA Strands (JOI16_selling_rna)Java
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef string str; typedef double db; typedef long double ld; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pi> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define FR(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define RF(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) const int MAXN = (int)(1e5) + 5; const int MAXNODES = (int)(2e6) + 5; //const int MAXN = 5; //const int MAXNODES = 20; struct Node { int to[4] = {-1, -1, -1, -1}; int leaf = -1; int cnt = 0; }; vi prefix[MAXN]; vi suffix[MAXN]; int cur[MAXN]; int ans[MAXN]; vector<Node> nodes; vi ss[MAXN]; vi ssrev[MAXN]; struct Trie { int root = -1; vector<int> leaves; int sz = 0; bool st = false; Trie() { root = nodes.size(); nodes.push_back({}); } int add(int i, vi& a) { sz += a.size(); leaves.push_back(i); return iter(root, 0, i, a); } int iter(int j, int cur, int i, vi& s) { nodes[j].cnt++; if (cur == s.size()) { int old = nodes[j].leaf; if (old == -1) { nodes[j].leaf = i; } return old; } if (nodes[j].to[s[cur]] == -1) { nodes[j].to[s[cur]] = nodes.size(); nodes.push_back({}); } return iter(nodes[j].to[s[cur]], cur+1, i, s); } int cnt(vi& a, int u, int cur = 0) { if (u == -1) { return 0; } if (cur == a.size()) { return nodes[u].cnt; } return cnt(a, nodes[u].to[a[cur]], cur+1); } }; Trie start; Trie ts[MAXN]; int tr[MAXNODES]; int merge(int u, int j) { if (ts[u].sz < ts[j].sz) { swap(u, j); } trav(v, ts[j].leaves) { ts[u].add(v, ssrev[v]); } return u; } void dfs(int u, vi& prefixes) { if (nodes[u].leaf != -1) { tr[u] = nodes[u].leaf; } vi send[5]; trav(a, prefixes) { if (cur[a] == prefix[a].size()) { send[4].push_back(a); } else { send[prefix[a][cur[a]++]].push_back(a); } } FR(i, 4) { if (nodes[u].to[i] != -1) { dfs(nodes[u].to[i], send[i]); if (tr[u] == -1) { tr[u] = tr[nodes[u].to[i]]; } else { tr[u] = merge(tr[u], tr[nodes[u].to[i]]); } } } trav(a, send[4]) { ans[a] = ts[tr[u]].cnt(suffix[a], ts[tr[u]].root); } } int conv[300]; int main() { str s = "input.in"; freopen(s.c_str(), "r", stdin); start.st = true; int N, M; memset(ans, 0, sizeof(ans)); cin >> N >> M; conv['A'] = 0; conv['G'] = 1; conv['C'] = 2; conv['U'] = 3; FR(i, MAXNODES) { tr[i] = -1; } FR(i, N) { string t; cin >> t; FR(j, t.size()) { ss[i].push_back(conv[t[j]]); ssrev[i].push_back(conv[t[j]]); } reverse(ssrev[i].begin(), ssrev[i].end()); int o = start.add(i, ss[i]); if (o == -1) { ts[i].add(i, ssrev[i]); } else { ts[o].add(i, ssrev[i]); } } vi ori; FR(i, M) { string pre, suff; cin >> pre >> suff; FR(j, pre.size()) { prefix[i].push_back(conv[pre[j]]); } FR(j, suff.size()) { suffix[i].push_back(conv[suff[j]]); } reverse(suffix[i].begin(), suffix[i].end()); ori.push_back(i); } dfs(start.root, ori); FR(i, M) { cout << ans[i] << '\n'; } }

Compilation message (stderr)

selling_rna.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
selling_rna.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
selling_rna.java:4: error: class, interface, or enum expected
typedef long long ll;
^
selling_rna.java:5: error: class, interface, or enum expected
typedef string str;
^
selling_rna.java:6: error: class, interface, or enum expected
typedef double db;
^
selling_rna.java:7: error: class, interface, or enum expected
typedef long double ld;
^
selling_rna.java:9: error: class, interface, or enum expected
typedef pair<int, int> pi;
^
selling_rna.java:10: error: class, interface, or enum expected
typedef  pair<ll, ll> pl;
^
selling_rna.java:12: error: class, interface, or enum expected
typedef vector<int> vi;
^
selling_rna.java:13: error: class, interface, or enum expected
typedef vector<ll> vl;
^
selling_rna.java:14: error: class, interface, or enum expected
typedef vector<pi> vpi;
^
selling_rna.java:17: error: illegal character: '#'
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
^
selling_rna.java:17: error: class, interface, or enum expected
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
        ^
selling_rna.java:17: error: class, interface, or enum expected
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
                                     ^
selling_rna.java:17: error: class, interface, or enum expected
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
                                              ^
selling_rna.java:18: error: illegal character: '#'
#define FR(i,a) FOR(i,0,a)
^
selling_rna.java:19: error: illegal character: '#'
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
^
selling_rna.java:19: error: class, interface, or enum expected
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
                                       ^
selling_rna.java:19: error: class, interface, or enum expected
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
                                                 ^
selling_rna.java:20: error: illegal character: '#'
#define RF(i,a) ROF(i,0,a)
^
selling_rna.java:21: error: illegal character: '#'
#define trav(a,x) for (auto& a: x)
^
selling_rna.java:23: error: class, interface, or enum expected
const int MAXNODES = (int)(2e6) + 5;
^
selling_rna.java:26: error: class, interface, or enum expected
struct Node {
^
selling_rna.java:28: error: class, interface, or enum expected
    int leaf = -1;
    ^
selling_rna.java:29: error: class, interface, or enum expected
    int cnt = 0;
    ^
selling_rna.java:30: error: class, interface, or enum expected
};
^
selling_rna.java:31: error: class, interface, or enum expected
vi prefix[MAXN];
^
selling_rna.java:32: error: class, interface, or enum expected
vi suffix[MAXN];
^
selling_rna.java:33: error: class, interface, or enum expected
int cur[MAXN];
^
selling_rna.java:34: error: class, interface, or enum expected
int ans[MAXN];
^
selling_rna.java:35: error: class, interface, or enum expected
vector<Node> nodes;
^
selling_rna.java:36: error: class, interface, or enum expected
vi ss[MAXN];
^
selling_rna.java:37: error: class, interface, or enum expected
vi ssrev[MAXN];
^
selling_rna.java:38: error: class, interface, or enum expected
struct Trie {
^
selling_rna.java:40: error: class, interface, or enum expected
    vector<int> leaves;
    ^
selling_rna.java:41: error: class, interface, or enum expected
    int sz = 0;
    ^
selling_rna.java:42: error: class, interface, or enum expected
    bool st = false;
    ^
selling_rna.java:43: error: class, interface, or enum expected
    Trie() {
    ^
selling_rna.java:45: error: class, interface, or enum expected
        nodes.push_back({});
        ^
selling_rna.java:46: error: class, interface, or enum expected
    }
    ^
selling_rna.java:49: error: class, interface, or enum expected
        leaves.push_back(i);
        ^
selling_rna.java:50: error: class, interface, or enum expected
        return iter(root, 0, i, a);
        ^
selling_rna.java:51: error: class, interface, or enum expected
    }
    ^
selling_rna.java:54: error: class, interface, or enum expected
        if (cur == s.size()) {
        ^
selling_rna.java:56: error: class, interface, or enum expected
            if (old == -1) {
            ^
selling_rna.java:58: error: class, interface, or enum expected
            }
            ^
selling_rna.java:60: error: class, interface, or enum expected
        }
        ^
selling_rna.java:63: error: class, interface, or enum expected
            nodes.push_back({});
            ^
selling_rna.java:64: error: class, interface, or enum expected
        }
        ^
selling_rna.java:66: error: class, interface, or enum expected
    }
    ^
selling_rna.java:70: error: class, interface, or enum expected
        }
        ^
selling_rna.java:73: error: class, interface, or enum expected
        }
        ^
selling_rna.java:75: error: class, interface, or enum expected
    }
    ^
selling_rna.java:77: error: class, interface, or enum expected
Trie start;
^
selling_rna.java:78: error: class, interface, or enum expected
Trie ts[MAXN];
^
selling_rna.java:79: error: class, interface, or enum expected
int tr[MAXNODES];
^
selling_rna.java:80: error: class, interface, or enum expected
int merge(int u, int j) {
^
selling_rna.java:83: error: class, interface, or enum expected
    }
    ^
selling_rna.java:86: error: class, interface, or enum expected
    }
    ^
selling_rna.java:88: error: class, interface, or enum expected
}
^
selling_rna.java:92: error: class, interface, or enum expected
    }
    ^
selling_rna.java:94: error: class, interface, or enum expected
    trav(a, prefixes) {
    ^
selling_rna.java:97: error: class, interface, or enum expected
        }
        ^
selling_rna.java:100: error: class, interface, or enum expected
        }
        ^
selling_rna.java:105: error: class, interface, or enum expected
            if (tr[u] == -1) {
            ^
selling_rna.java:107: error: class, interface, or enum expected
            }
            ^
selling_rna.java:110: error: class, interface, or enum expected
            }
            ^
selling_rna.java:115: error: class, interface, or enum expected
    }
    ^
selling_rna.java:119: error: class, interface, or enum expected
int main() {
^
selling_rna.java:121: error: class, interface, or enum expected
    freopen(s.c_str(), "r", stdin);
    ^
selling_rna.java:122: error: class, interface, or enum expected
    start.st = true;
    ^
selling_rna.java:123: error: class, interface, or enum expected
    int N, M;
    ^
selling_rna.java:124: error: class, interface, or enum expected
    memset(ans, 0, sizeof(ans));
    ^
selling_rna.java:125: error: class, interface, or enum expected
    cin >> N >> M;
    ^
selling_rna.java:126: error: class, interface, or enum expected
    conv['A'] = 0;
    ^
selling_rna.java:127: error: class, interface, or enum expected
    conv['G'] = 1;
    ^
selling_rna.java:128: error: class, interface, or enum expected
    conv['C'] = 2;
    ^
selling_rna.java:129: error: class, interface, or enum expected
    conv['U'] = 3;
    ^
selling_rna.java:131: error: class, interface, or enum expected
    FR(i, MAXNODES) {
    ^
selling_rna.java:133: error: class, interface, or enum expected
    }
    ^
selling_rna.java:136: error: class, interface, or enum expected
        cin >> t;
        ^
selling_rna.java:137: error: class, interface, or enum expected
        FR(j, t.size()) {
        ^
selling_rna.java:139: error: class, interface, or enum expected
            ssrev[i].push_back(conv[t[j]]);
            ^
selling_rna.java:140: error: class, interface, or enum expected
        }
        ^
selling_rna.java:142: error: class, interface, or enum expected
        int o = start.add(i, ss[i]);
        ^
selling_rna.java:143: error: class, interface, or enum expected
        if (o == -1) {
        ^
selling_rna.java:145: error: class, interface, or enum expected
        }
        ^
selling_rna.java:148: error: class, interface, or enum expected
        }
        ^
selling_rna.java:151: error: class, interface, or enum expected
    FR(i, M) {
    ^
selling_rna.java:153: error: class, interface, or enum expected
        cin >> pre >> suff;
        ^
selling_rna.java:154: error: class, interface, or enum expected
        FR(j, pre.size()) {
        ^
selling_rna.java:156: error: class, interface, or enum expected
        }
        ^
selling_rna.java:159: error: class, interface, or enum expected
        }
        ^
selling_rna.java:161: error: class, interface, or enum expected
        ori.push_back(i);
        ^
selling_rna.java:162: error: class, interface, or enum expected
    }
    ^
selling_rna.java:164: error: class, interface, or enum expected
    FR(i, M) {
    ^
selling_rna.java:166: error: class, interface, or enum expected
    }
    ^
97 errors