submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s018220252
p03972
C++
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <cstring> using namespace std; #define rep(l,n) for(int l = 0; l < (n); l++) #define rep2(i,k,n) for(int i = (k); i < (n); i++) inline void readInt2(int *a, int *b) { int c, p = 0; char s[20] = ""; for(int i = 0; (c = getchar()) != '\n'; ++i) { if (c == ' ') { *a = atoi(s); strcpy(s, ""); p = i+1; continue; } else s[i] = c; } *b = atoi(s+p); } /*inline void readInt3(int *a, int *b, int *c) { int d, p = 0; char s[20] = ""; for(int i = 0; (d = getchar()) != '\n'; i++) { if(d == ' ') { if(p == 0) { *a = atoi(s); strcpy(s, ""); p = i+1; } else {*b = atoi(s+p); strcpy(s, ""); p = i+1; } } else s[i] = d; } *c = atoi(s+p); }*/ inline void readInt(int *a) { int c; char s[20] = ""; for (int i = 0; (c = getchar()) != '\n'; ++i) s[i] = c; *a = atoi(s); } int parent[10000000], rank[1000000]; void uf_init(int n); void unite(int x, int y); bool same(int x, int y); int find(int x); // kruskal struct edge { int u, v, cost; }; bool comp(const edge &e1, const edge &e2) { return e1.cost < e2.cost; } vector<edge> v; edge es; int N, M; // 頂点数と辺の数 int kruskal() { int res = 0; uf_init(N); sort(v.begin(), v.end(), comp); rep(i,M) { //cout << v[i].u << " " << v[i].v << " " << v[i].cost << endl; edge e = v[i]; if (!same(e.u, e.v)) { //cout << e.u << " " << e.v << endl; unite(e.u, e.v); res += e.cost; } } return res; } // Union Find void uf_init(int n) { rep(i,n+1) { parent[i] = i; rank[i] = 0; } } int find(int x) { if (parent[x] == x) return x; else return parent[x] = find(parent[x]); } void unite(int x, int y) { x = find(x); y = find(y); if(x == y) return; if (rank[x] < rank[y]) parent[x] = y; else { parent[y] = x; if(rank[x] == rank[y]) rank[x]++; } } bool same(int x, int y) { return find(x) == find(y); } int main(void) { int H, W, p, q; readInt2(&W, &H); N = (W+1) * (H+1); //cout << W << " " << H << endl; for (int i = 0; i < W; i++) { readInt(&p); rep(j,H+1) { edge e; e.u = i+j*(W+1); e.v = i+j*(W+1)+1; e.cost = p; v.push_back(e); } } for (int i = 0; i < H; i++) { readInt(&q); rep(j,W+1) { edge e; e.u = i*(W+1)+j; e.v = i*(W+1)+(W+1)+j; e.cost = q; v.push_back(e); } } M = W*(H+1) + H*(W+1); /*for (int i = 0; i < M; i++) { cout << v[i].u << " " << v[i].v << " " << v[i].cost << endl; }*/ printf("%d\n",kruskal()); return 0; }
a.cc: In function 'void uf_init(int)': a.cc:73:31: error: reference to 'rank' is ambiguous 73 | rep(i,n+1) { parent[i] = i; rank[i] = 0; } | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:23: note: 'int rank [1000000]' 36 | int parent[10000000], rank[1000000]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:83:7: error: reference to 'rank' is ambiguous 83 | if (rank[x] < rank[y]) parent[x] = y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:23: note: 'int rank [1000000]' 36 | int parent[10000000], rank[1000000]; | ^~~~ a.cc:83:17: error: reference to 'rank' is ambiguous 83 | if (rank[x] < rank[y]) parent[x] = y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:23: note: 'int rank [1000000]' 36 | int parent[10000000], rank[1000000]; | ^~~~ a.cc:86:8: error: reference to 'rank' is ambiguous 86 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:23: note: 'int rank [1000000]' 36 | int parent[10000000], rank[1000000]; | ^~~~ a.cc:86:19: error: reference to 'rank' is ambiguous 86 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:23: note: 'int rank [1000000]' 36 | int parent[10000000], rank[1000000]; | ^~~~ a.cc:86:28: error: reference to 'rank' is ambiguous 86 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:23: note: 'int rank [1000000]' 36 | int parent[10000000], rank[1000000]; | ^~~~
s372673735
p03972
C++
#include <iostream> #include <vector> using namespace std; #define MAX 100000 int W,H; int numW=0,numH=0; int result=0; int p[100000],q[100000]; bool pairCompare(const std::pair<float, int>& firstElem, const std::pair<float, int>& secondElem) { return firstElem.second < secondElem.second; } int main(){ vector<pair<int,int> > pq; cin >> W >> H; for(int i=0;i<W;i++){cin >> p[i];} for(int i=0;i<H;i++){cin >> q[i];} for(int i=0;i<W;i++){ pq.push_back(make_pair(i,p[i])); } for(int i=0;i<H;i++){ pq.push_back(make_pair(i+W,q[i])); } sort(begin(pq), end(pq), pairCompare); for(int i = 0; i < H+W;i++){ if(pq[i].first<W){ //cout << pq[i].second <<"$"<<(W+1-numW)<<endl; result += pq[i].second*(H+1-numH); numW++; } else{ //cout << pq[i].second <<"$"<<(H+1-numH)<<endl; result += pq[i].second*(W+1-numW); numH++; } } cout << result << endl; }
a.cc: In function 'int main()': a.cc:29:3: error: 'sort' was not declared in this scope; did you mean 'short'? 29 | sort(begin(pq), end(pq), pairCompare); | ^~~~ | short
s688750642
p03972
C++
#include <iostream> #include <vector> using namespace std; #define MAX 100000 int W,H; int numW=0,numH=0; int result=0; int p[100000],q[100000]; bool pairCompare(const std::pair<float, int>& firstElem, const std::pair<float, int>& secondElem) { return firstElem.second < secondElem.second; } int main(){ vector<pair<int,int> > pq; cin >> W >> H; for(int i=0;i<W;i++){cin >> p[i];} for(int i=0;i<H;i++){cin >> q[i];} for(int i=0;i<W;i++){ pq.push_back(make_pair(i,p[i])); } for(int i=0;i<H;i++){ pq.push_back(make_pair(i+W,q[i])); } sort(begin(pq), end(pq), pairCompare); for(int i = 0; i < H+W;i++){ if(pq[i].first<W){ //cout << pq[i].second <<"$"<<(W+1-numW)<<endl; result += pq[i].second*(H+1-numH); numW++; } else{ //cout << pq[i].second <<"$"<<(H+1-numH)<<endl; result += pq[i].second*(W+1-numW); numH++; } } cout << result << endl; }
a.cc: In function 'int main()': a.cc:29:3: error: 'sort' was not declared in this scope; did you mean 'short'? 29 | sort(begin(pq), end(pq), pairCompare); | ^~~~ | short
s003598658
p03972
C++
#include <iostream> #include <vector> #include <functional> #include <algorithm> using namespace std; int main() { long long int w, h; cin >> w >> h; vector<long long int> p(w); vector<long long int> q(h); for (long long int i = 0; i < w; i++) { cin >> p[i]; } for (long long int i = 0; i < h; i++) { cin >> q[i]; } sort(p.begin(), p.end(), greater<long long int>()); sort(q.begin(), q.end(), greater<long long int>()); long long int ww, hh; long long int pp, qq; pp = qq = 0; ww = w; hh = h; long long int cc = 0; bool h = true; while (true) { if (pp == p.size()) { if (qq == q.size()) { break; } else { cc += q[qq]*ww; qq++; hh--; } } else if (qq == q.size()) { c += p[pp]*hh; pp++; ww--; } else { if (p[pp] < q[qq]) { c += p[pp]*ww; pp++; hh--; } else if (q[qq] < p[pp]) { c += q[qq]*hh; qq++; ww--; } else { break; } } } cout << cc << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:14: error: conflicting declaration 'bool h' 28 | bool h = true; | ^ a.cc:9:26: note: previous declaration as 'long long int h' 9 | long long int w, h; | ^ a.cc:39:25: error: 'c' was not declared in this scope; did you mean 'cc'? 39 | c += p[pp]*hh; | ^ | cc a.cc:44:33: error: 'c' was not declared in this scope; did you mean 'cc'? 44 | c += p[pp]*ww; | ^ | cc a.cc:48:33: error: 'c' was not declared in this scope; did you mean 'cc'? 48 | c += q[qq]*hh; | ^ | cc
s684807019
p03972
C++
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<long long> vl; typedef pair<int,int> pii; typedef pair<long,long> pll; typedef long long ll; typedef vector<pii> vpii; #define reps(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) reps(i,0,n) #define all(g) (g).begin(),(g).end() #define pb push_back const int mod = 1e9 + 7; #define INF 1<<25 /* input case output case */ // ll W,H; // const ll max_s = 100100; // const ll max_v = max_s * max_s; // int color[max_s][max_s]; // ll M[max_s][max_s]; int W, H; const int max_s = 100100; int color[max_s][max_s]; ll p[max_s]; ll q[max_s]; ll d[max_s][max_s]; pii z[max_s][max_s]; int tee,u,s; void solve(){ ll mincost; d[0][0] = 0; z[0][0] = make_pair(0,-1); while(true){ mincost = INF; rep(i,W) rep(j,H){ if ((color[i][j] != 2) and(d[i][j] < mincost)){ mincost = d[i][j]; u = i; s = j; } } if (mincost == INF) break; color[u][s] = 2; rep(i,W) rep(j,H){ if ((color[i][j] != 2) and ((i == u and abs(j-s) == 1) or (abs(i-u) == 1 and j == s))){ if ((i == u) and (abs(j-s) == 1)){ tee = q[max(j,s)];} if ((abs(i-u) == 1) and (s == j)){ tee = p[max(i,u)];} d[i][j] = tee; z[i][j] = make_pair(u,s); color[i][j] = 1; } } } int sum = 0; rep(i,W) rep(j,H){ if ((z[i][j].first != -1) or (z[i][j].second != -1)) { if (abs(z[i][j].first - i) == 1){ sum += p[z[i][j].first]; }else{ sum += q[z[i][j].second]; } } } cout << sum << endl; } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> W >> H; rep(i,W) cin >> p[i]; rep(i,H) cin >> q[i]; rep(i,W) rep(j,H) color[i][j] = 0; rep(i,W) rep(j,H) d[i][j] = INF; solve(); }
/tmp/ccnr0B6E.o: in function `solve()': a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccnr0B6E.o a.cc:(.text+0x42): relocation truncated to fit: R_X86_64_PC32 against symbol `z' defined in .bss section in /tmp/ccnr0B6E.o a.cc:(.text+0xba): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccnr0B6E.o a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccnr0B6E.o a.cc:(.text+0xf9): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccnr0B6E.o a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccnr0B6E.o a.cc:(.text+0x13c): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccnr0B6E.o a.cc:(.text+0x142): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccnr0B6E.o a.cc:(.text+0x1b8): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccnr0B6E.o a.cc:(.text+0x1c5): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccnr0B6E.o a.cc:(.text+0x1dc): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s701387400
p03972
C++
#include <iostream> #include <sstream> #include <string> #include <cmath> #include <cstdio> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <functional> #include <numeric> #include <iomanip> #include <climits> using namespace std; typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; #define REP(i,n) for(int i = 0; i < (int)(n); ++i) #define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i) #define ALL(c) (c).begin(), (c).end() #define SIZE(v) ((int)v.size()) #define pb push_back #define mp make_pair #define mt make_tuple // (譛€蟆丞€、, 譛€蟆丞€、繧偵→繧九う繝ウ繝・ャ繧ッ繧ケ)縺ョ繝壹い繧定ソ斐☆ // 隍・焚縺ョ蛟、縺悟酔譎ゅ↓譛€蟆丞€、繧貞叙繧句エ蜷医・縺ゥ縺。繧峨・繧、繝ウ繝・ャ繧ッ繧ケ縺瑚ソ斐k縺倶ソ晁ィシ縺後↑縺・・縺ァ豕ィ諢・class SegmentTreeWithIndex { private: int m_n; //(min, idx)縺ョ繝壹い vector<pair<int,int>> m_dat; public: void init(int n) { m_n = 1; while (m_n < n) m_n *= 2; m_dat.resize(2 * m_n - 1, mp(INT_MAX,-1)); } void update(int k, int a) { int orig_k = k; k += m_n - 1; m_dat[k] = mp(a,orig_k); while (k > 0) { k = (k - 1) / 2; auto v1 = m_dat[k * 2 + 1].first; auto v2 = m_dat[k * 2 + 2].first; if (v1 < v2) { m_dat[k] = mp(v1, m_dat[k * 2 + 1].second); } else { m_dat[k] = mp(v2, m_dat[k * 2 + 2].second); } } // cout << "m_dat:" << endl; // for(auto d: m_dat) cout << "(" << d.first << "," << d.second << "),"; // cout << endl; } // [a, b)縺ョ遽・峇縺ァ譛€蟆丞€、繧定ソ斐☆ pair<int,int> query(int a, int b) { return queryInternal(a, b, 0, 0, m_n); } private: pair<int,int> queryInternal(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return mp(INT_MAX,-1); if (a <= l && r <= b) return m_dat[k]; // ? else { auto vl = queryInternal(a, b, k * 2 + 1, l, (l + r) / 2); auto vr = queryInternal(a, b, k * 2 + 2, (l + r) / 2, r); return (vl.first < vr.first) ? vl : vr; } } }; int W, H; vector<int> Ps; vector<int> Qs; SegmentTreeWithIndex pseg; SegmentTreeWithIndex qseg; int offset = 100000009; ll mysum(vector<int>& PorQ, int mn, int mx) { ll ans = 0; FOR(i, mn, mx) { ans += PorQ[i]; } return ans; } ll func(int p_min, int p_max, int q_min, int q_max) { if (p_min == p_max && q_min == q_max) { return 0; } if (p_min == p_max) { return mysum(Qs, q_min, q_max); } if (q_min == q_max) { return mysum(Ps, p_min, p_max); } auto max_p_data = pseg.query(p_min, p_max); auto max_q_data = qseg.query(q_min, q_max); auto max_p_idx = max_p_data.second; auto max_q_idx = max_q_data.second; auto max_p = Ps[max_p_idx]; auto max_q = Qs[max_q_idx]; if (max_p < max_q) { auto ans1 = func(p_min, p_max, q_min, max_q_idx); auto ans2 = func(p_min, p_max, max_q_idx + 1, q_max); return ans1 + ans2 + max_q; } else { auto ans1 = func(p_min, max_p_idx, q_min, q_max); auto ans2 = func(max_p_idx + 1, p_max, q_min, q_max); return ans1 + ans2 + max_p; } } int main(void) { cin >> W >> H; Ps.resize(W); Qs.resize(H); REP(w,W) cin >> Ps[w]; REP(h,H) cin >> Qs[h]; pseg.init(W); qseg.init(H); REP(w,W) { pseg.update(w, offset - Ps[w]); } REP(h,H) { qseg.update(h, offset - Qs[h]); } cout << func(0, W, 0, H) << endl; return 0; }
a.cc:33:1: error: expected unqualified-id before '{' token 33 | { | ^ a.cc:90:1: error: 'SegmentTreeWithIndex' does not name a type 90 | SegmentTreeWithIndex pseg; | ^~~~~~~~~~~~~~~~~~~~ a.cc:91:1: error: 'SegmentTreeWithIndex' does not name a type 91 | SegmentTreeWithIndex qseg; | ^~~~~~~~~~~~~~~~~~~~ a.cc: In function 'll func(int, int, int, int)': a.cc:114:23: error: 'pseg' was not declared in this scope 114 | auto max_p_data = pseg.query(p_min, p_max); | ^~~~ a.cc:115:23: error: 'qseg' was not declared in this scope 115 | auto max_q_data = qseg.query(q_min, q_max); | ^~~~ a.cc: In function 'int main()': a.cc:141:5: error: 'pseg' was not declared in this scope 141 | pseg.init(W); | ^~~~ a.cc:142:5: error: 'qseg' was not declared in this scope 142 | qseg.init(H); | ^~~~
s967135460
p03972
C++
#include <cstdio> #include <algorithm> #include <iostream> #include <vector> #define MAX_N 100010 using namespace std; int par[MAX_N]; int rank[MAX_N]; void init(int n){ for(int i=0;i<n;i++){ par[i]=i; rank[i]=0; } } int find(int x){ if(par[x]==x){ return x; } else { return par[x]=find(par[x]); } } void unite(int x ,int y){ x=find(x); y=find(y); if(x==y) return ; if(rank[x]<rank[y]){ par[x]=y; }else { par[y]=x; if(rank[x]==rank[y]) rank[x]++; } } bool same(int x,int y) { return find(x)==find(y); } struct edge{int u,v,cost;}; bool comp(const edge& e1,const edge& e2){ return e1.cost<e2.cost; } edge es[MAX_N]; int V,E; int kruskal(){ sort(es,es+E,comp); init(V); int res=0; for(int i=0;i<E;i++){ edge e=es[i]; if(!same(e.u,e.v)){ unite(e.u,e.v); res += e.cost; } } return res; } int main(void){ string S; int W,H; int res=0; int ai=0,bi=0; cin>>W>>H; int i,j; vector<int> p(W); vector<int> q(H); int k=0; for(i=0;i<W;i++) cin>>p[i]; for(i=0;i<H;i++) cin>>q[i]; V=(W+1)*(W+1); E=((W+1)*H)+(W*(H+1)); k=0; for(j=0;j<=H;j++){ for(i=0;i<=W;i++) { if(i<W){ es[k].u=j*(W+1)+i; es[k].v=j*(W+1)+i+1; es[k].cost=p[i]; k++; } if(j<H){ es[k].u=j*(W+1)+i; es[k].v=j*(W+1)+i+W+1; es[k].cost=q[j]; k++; } } } res=kruskal(); cout<<res<<endl; return 0; }
a.cc: In function 'void init(int)': a.cc:15:5: error: reference to 'rank' is ambiguous 15 | rank[i]=0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from a.cc:2: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:32:6: error: reference to 'rank' is ambiguous 32 | if(rank[x]<rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~ a.cc:32:14: error: reference to 'rank' is ambiguous 32 | if(rank[x]<rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~ a.cc:36:8: error: reference to 'rank' is ambiguous 36 | if(rank[x]==rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~ a.cc:36:17: error: reference to 'rank' is ambiguous 36 | if(rank[x]==rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~ a.cc:36:26: error: reference to 'rank' is ambiguous 36 | if(rank[x]==rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~
s505400601
p03972
C++
#include <iostream> #include <string> #include <vector> #include <queue> using namespace std; #define ll long long int struct node{ int x,y; ll val; bool operator <(const node & a) const{ return val>a.val; } node(int xx,int yy,int vall):x(xx),y(yy),val(vall){} }; int main(){ int W,H; cin>>W>>H; vector<ll> p(W); vector<ll> q(H); ll res=0; priority_queue<node> qu; int i,j,k; for(i=0;i<W;i++) cin>>p[i]; for(i=0;i<H;i++) cin>>q[i]; vector<vector<int>> visit(W+1,vector<int>(H+1,INT_MAX)); int dir[4][2]={{-1,0},{1,0},{0,1},{0,-1}}; qu.push(node(0,0,0)); visit[0][0]=0; while(!qu.empty()){ node pp=qu.top(); qu.pop(); if(pp.val!=visit[pp.x][pp.y]) continue; res+=pp.val; visit[pp.x][pp.y]=-1; for(i=0;i<4;i++){ int x=pp.x+dir[i][0],y=pp.y+dir[i][1]; if(x>=0&&x<=W&&y>=0&&y<=H&&visit[x][y]!=-1){ int c; if(x==pp.x+1) c=p[pp.x]; else if(x==pp.x-1) c=p[x]; else if(y==pp.y+1) c=q[pp.y]; else c=q[y]; if(visit[x][y]>c){ visit[x][y]=c; qu.push(node(x,y,c)); } } } } cout<<res<<endl; return 0; }
a.cc: In function 'int main()': a.cc:26:55: error: 'INT_MAX' was not declared in this scope 26 | vector<vector<int>> visit(W+1,vector<int>(H+1,INT_MAX)); | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <queue> +++ |+#include <climits> 5 | using namespace std;
s777965242
p03972
C++
#include <string> #include <sstream> #include <iostream> #include <vector> #include <math.h> #include <algorithm> #include <functional> #include <map> #include <unordered_map> #include <climits> using namespace std; #define int long #define rep(i,n) for (int i=0; i < int(n); i++) // 素集合データ構造 struct UnionFind { // par[i]:データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである vector<int> par; // sizes[i]:根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる vector<int> sizes; UnionFind(int n) : par(n), sizes(n, 1) { // 最初は全てのデータiがグループiに存在するものとして初期化 rep(i, n) par[i] = i; } // データxが属する木の根を得る int find(int x) { if (x == par[x]) return x; return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す } // 2つのデータx, yが属する木をマージする void unite(int x, int y) { // データの根ノードを得る x = find(x); y = find(y); // 既に同じ木に属しているならマージしない if (x == y) return; // xの木がyの木より大きくなるようにする if (sizes[x] < sizes[y]) swap(x, y); // xがyの親になるように連結する par[y] = x; sizes[x] += sizes[y]; // sizes[y] = 0; // sizes[y]は無意味な値となるので0を入れておいてもよい } // 2つのデータx, yが属する木が同じならtrueを返す bool same(int x, int y) { return find(x) == find(y); } // データxが含まれる木の大きさを返す int size(int x) { return sizes[find(x)]; } }; // 頂点a, bをつなぐコストcostの(無向)辺 struct Edge { int a, b, cost; // コストの大小で順序定義 bool operator<(const Edge& o) const { return cost < o.cost; } }; // 頂点数と辺集合の組として定義したグラフ struct Graph { int n; // 頂点数 vector<Edge> es; // 辺集合 // クラスカル法で無向最小全域木のコストの和を計算する // グラフが非連結のときは最小全域森のコストの和となる int kruskal() { // コストが小さい順にソート sort(es.begin(), es.end()); UnionFind uf(n); int min_cost = 0; rep(ei, es.size()) { Edge& e = es[ei]; if (!uf.same(e.a, e.b)) { // 辺を追加しても閉路ができないなら、その辺を採用する min_cost += e.cost; uf.unite(e.a, e.b); } } return min_cost; } }; class Main { public: int getNum(int x, int y, int w) { return y * (w + 1) + x; } int getX(int num, int w) { return num % (w + 1); } int getY(int num, int w) { return num / (w + 1); } int mst(vector<int> ps, vector<int> qs) { Graph graph; int w = ps.size(); int h = qs.size(); graph.n = w*(h+1)+(w+1)*h; for (int i = 0;i < w;i++) { for (int j = 0;j < h + 1;j++) { Edge e{ getNum(i, j, w), getNum(i + 1, j, w), ps[i] }; graph.es.push_back(e); } } for (int i = 0;i < w + 1;i++) { for (int j = 0;j < h;j++) { Edge e{ getNum(i, j, w), getNum(i, j + 1, w), qs[j] }; graph.es.push_back(e); } } int ans = graph.kruskal(); return ans; } }; int main() { Main m; int w, h; vector<int> ps; vector<int> qs; cin >> w >> h; for (int i = 0;i < w;i++) { int inp; cin >> inp; ps.push_back(inp); } for (int i = 0;i < h;i++) { int inp; cin >> inp; qs.push_back(inp); } cout << m.mst(ps, qs) << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s958642828
p03972
C++
#include<bits/stdc++.h> using namespace std; int main() { pair<long long int, pair<long long int, long long int>>; long long int W, H; cin >> W >> H; vector<long long int>P( W ), Q( H ); for( size_t i = 0; i < W; i++ ) { cin >> P[i]; } for( size_t i = 0; i < H; i++ ) { cin >> Q[i]; } vector<vector<long long int>>D( W + 1, vector<long long int>( H + 1, LLONG_MAX / 6 ) ); //D[0][0] = 0; priority_queue<pair<long long int, pair<long long int, long long int>>, vector<pair<long long int, pair<long long int, long long int>>>, greater<pair<long long int, pair<long long int, long long int>>>>que; que.push( make_pair( 0, make_pair( 0, 0 ) ) ); long long int ans = 0; while( que.size() ) { auto now = que.top(); que.pop(); //cout << now.second.first << " " << now.second.second << endl; if( D[now.second.first][now.second.second] != LLONG_MAX / 6 ) { continue; } D[now.second.first][now.second.second] = 0; ans += now.first; if( now.second.first + 1 <= W &&now.second.first >= 0 ) { que.push( make_pair( P[now.second.first], make_pair( now.second.first + 1, now.second.second ) ) ); } if( now.second.first > 0 && now.second.first < W ) { que.push( make_pair( P[now.second.first], make_pair( now.second.first - 1, now.second.second ) ) ); } if( now.second.second + 1 <= H&&now.second.second >= 0 ) { que.push( make_pair( Q[now.second.second], make_pair( now.second.first, now.second.second + 1 ) ) ); } if( now.second.second > 0 && now.second.second < H ) { que.push( make_pair( Q[now.second.second], make_pair( now.second.first, now.second.second - 1 ) ) ); } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:10:9: error: declaration does not declare anything [-fpermissive] 10 | pair<long long int, pair<long long int, long long int>>; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s875529819
p03972
C++
#include <iostream> #include <string> #include <vector> using namespace std; typedef struct point { int _x; int _y; int _cost; point(int x, int y, int cost) { _x = x; _y = y; _cost = cost; } } Point; int main() { int W, H; cin >> W >> H; vector<int> q_w, q_h; for (int i = 0; i < W; i++) { int q; cin >> q; q_w.push_back(q); } for (int i = 0; i < H; i++) { int q; cin >> q; q_h.push_back(q); } int cost = 0; vector<Point> fin; // 道路が通っている点 for (int i = 0; i < W; i++) { for (int j = 0; j < H; j++) { vector<Point> seack; if (i - 1 >= 0 && !find(fin, Point(i - 1, j, q_w[i - 1]))) seack.push_back(Point(i - 1, j, q_w[i - 1])); if (i + 1 <= W && !find(fin, Point(i + 1, j, q_w[i + 1]))) seack.push_back(Point(i + 1, j, q_w[i + 1])); if (j - 1 >= 0 && !find(fin, Point(i, j - 1, q_h[j - 1]))) seack.push_back(Point(i, j - 1, q_h[j - 1])); if (j + 1 <= H && !find(fin, Point(i, j + 1, q_h[j + 1]))) seack.push_back(Point(i, j + 1, q_h[j + 1])); int temp = -1; int idx = -1; for (int i = 0; i < seack.size(); i++) { if (temp == -1) { temp = seack[i]._cost; idx = i; } else if (temp > seack[i]._cost) { temp = seack[i]._cost; idx = i; } } cost += temp; fin.push_back(seack[i]); } } cout << cost << endl; return 0; } bool find(vector<Point> v, Point p) { bool result = false; for (int i = 0; i < v.size(); i++) { if (v[i]._x == p._x && v[i]._y == p._y) { result = true; break; } } return result; }
a.cc: In function 'int main()': a.cc:37:48: error: no matching function for call to 'find(std::vector<point>&, Point)' 37 | if (i - 1 >= 0 && !find(fin, Point(i - 1, j, q_w[i - 1]))) seack.push_back(Point(i - 1, j, q_w[i - 1])); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 2 provided a.cc:38:48: error: no matching function for call to 'find(std::vector<point>&, Point)' 38 | if (i + 1 <= W && !find(fin, Point(i + 1, j, q_w[i + 1]))) seack.push_back(Point(i + 1, j, q_w[i + 1])); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 2 provided a.cc:39:48: error: no matching function for call to 'find(std::vector<point>&, Point)' 39 | if (j - 1 >= 0 && !find(fin, Point(i, j - 1, q_h[j - 1]))) seack.push_back(Point(i, j - 1, q_h[j - 1])); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 2 provided a.cc:40:48: error: no matching function for call to 'find(std::vector<point>&, Point)' 40 | if (j + 1 <= H && !find(fin, Point(i, j + 1, q_h[j + 1]))) seack.push_back(Point(i, j + 1, q_h[j + 1])); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 2 provided
s770736647
p03972
C++
#include <stdio.h> #include <stdlib.h> #define MAXNODE 100000*100000 #define MAXEDGE MAXNODE #define Max(a,b) ((a)>(b)?(a):(b)) #define Min(a,b) ((a)<(b)?(a):(b)) typedef struct{ int cost; int node[2]; } Edge; typedef struct{ int x,y; } Node; typedef struct unode{ int rank; struct unode *p; } UNode; int makeEdge(Edge *edge,Node *node,int *p,int *q,int n){ int i,j,k; k=0; for(i=0;i<n;++i){ for(j=0;j<n;++j){ if((node[i].y==node[j].y)&&(node[j].x-node[i].x==1)){ edge[k].cost=p[node[i].x]; edge[k].node[0]=i; edge[k].node[1]=j; ++k; }else if((node[i].x==node[j].x)&&(node[j].y-node[i].y==1)){ edge[k].cost=q[node[i].x]; edge[k].node[0]=i; edge[k].node[1]=j; ++k; } } } return k; } int cmp(const void *a,const void *b){ Edge *A=(Edge*)a; Edge *B=(Edge*)b; return ((A->cost)>(B->cost))?1:-1; } void set(UNode *un){ un->p=un; un->rank=0; return; } UNode *find(UNode *un){ if(un!=(un->p)){ un->p=find(un->p); } return un->p; } int same(UNode *x,UNode *y){ return find(x)==find(y); } void link(UNode *x,UNode *y){ if((x->rank)>(y->rank)){ y->p=x; }else{ x->p=y; if((x->rank)==(y->rank)){ ++(y->rank); } } return; } void unite(UNode *x,UNode *y){ link(find(x),find(y)); return; } int kruskal(Edge *edge,int *used,int n,int m){ int i,j; int r; UNode un[MAXNODE]; for(i=0;i<n;++i){ set(un+i); } r=-1; j=0; for(i=0;i<m;++i){ if(same(un+edge[i].node[0],un+edge[i].node[1])){ continue; } unite(un+edge[i].node[0],un+edge[i].node[1]); used[j++]=i; if((((un+edge[i].node[0])->p)->rank)==n-1){ r=0; break; } } return r; } int main(){ int w,h; int p[100000],q[100000]; Node node[MAXNODE]; int n; int i,j,k; int m; Edge edge[MAXEDGE]; int used[MAXNODE-1]; int ans; scanf("%d %d",&w,&h); for(i=0;i<w;++i){ scanf("%d",p+i); } for(i=0;i<h;++i){ scanf("%d",q+i); } k=0; for(i=0;i<w;++i){ for(j=0;j<h;++j){ node[k].x=i; node[k].y=j; ++k; } } n=w*h; m=makeEdge(edge,node,p,q,w*h); qsort(edge,m,sizeof(Edge),cmp); kruskal(edge,used,n,m); ans=0; for(i=0;i<n-1;++i){ ans+=edge[used[i]].cost; } printf("%d\n",ans); return 0; }
a.cc: In function 'int kruskal(Edge*, int*, int, int)': a.cc:4:23: warning: integer overflow in expression of type 'int' results in '1410065408' [-Woverflow] 4 | #define MAXNODE 100000*100000 | ~~~~~~^~~~~~~ a.cc:105:13: note: in expansion of macro 'MAXNODE' 105 | UNode un[MAXNODE]; | ^~~~~~~ a.cc:4:23: error: size of array 'un' exceeds maximum object size '9223372036854775807' 4 | #define MAXNODE 100000*100000 | ~~~~~~^~~~~~~ a.cc:105:13: note: in expansion of macro 'MAXNODE' 105 | UNode un[MAXNODE]; | ^~~~~~~ a.cc: In function 'int main()': a.cc:4:23: warning: integer overflow in expression of type 'int' results in '1410065408' [-Woverflow] 4 | #define MAXNODE 100000*100000 | ~~~~~~^~~~~~~ a.cc:134:14: note: in expansion of macro 'MAXNODE' 134 | Node node[MAXNODE]; | ^~~~~~~ a.cc:4:23: error: size of array 'node' exceeds maximum object size '9223372036854775807' 4 | #define MAXNODE 100000*100000 | ~~~~~~^~~~~~~ a.cc:134:14: note: in expansion of macro 'MAXNODE' 134 | Node node[MAXNODE]; | ^~~~~~~ a.cc:4:23: warning: integer overflow in expression of type 'int' results in '1410065408' [-Woverflow] 4 | #define MAXNODE 100000*100000 | ~~~~~~^~~~~~~ a.cc:5:17: note: in expansion of macro 'MAXNODE' 5 | #define MAXEDGE MAXNODE | ^~~~~~~ a.cc:138:14: note: in expansion of macro 'MAXEDGE' 138 | Edge edge[MAXEDGE]; | ^~~~~~~ a.cc:4:23: error: size of array 'edge' exceeds maximum object size '9223372036854775807' 4 | #define MAXNODE 100000*100000 | ~~~~~~^~~~~~~ a.cc:5:17: note: in expansion of macro 'MAXNODE' 5 | #define MAXEDGE MAXNODE | ^~~~~~~ a.cc:138:14: note: in expansion of macro 'MAXEDGE' 138 | Edge edge[MAXEDGE]; | ^~~~~~~ a.cc:4:23: warning: integer overflow in expression of type 'int' results in '1410065408' [-Woverflow] 4 | #define MAXNODE 100000*100000 | ~~~~~~^~~~~~~ a.cc:139:13: note: in expansion of macro 'MAXNODE' 139 | int used[MAXNODE-1]; | ^~~~~~~ a.cc:139:20: error: size of array 'used' exceeds maximum object size '9223372036854775807' 139 | int used[MAXNODE-1]; | ^
s262646036
p03972
C++
#include <iostream> #include <string> #include <vector> #include <stack> #include <ctime> #include <unordered_map> #include <unordered_set> #include <sstream> #include <set> #include <list> #include <queue> #include <utility> #include <algorithm> #include <functional> #include <bitset> #include <array> #include <stdlib.h> #include <thread> #include <chrono> #include <map> #include <set> #include <stdio.h> #include <math.h> #include <fenv.h> using namespace std; using namespace std; template<class T> void printVector(const std::vector<T>& vs) { for(auto t : vs) std::cout << t << " "; std::cout << std::endl; } int cal(int w, int h, int* p, int *q) { std::sort(p, p+w); std::sort(q, q+h); long long mulq = w +1; long long mulp = h+ 1; int pi = 0; int qi = 0; long long res = 0; while (pi < w || qi < h) { if (p[pi] < q[qi]) { res += p[pi] * mulp; mulq--; pi++; } else { res += q[qi] * mulq; mulp--; qi++; } } return res; } int main() { int w, h; std::cin>>w>>h; int *p = new int[w+1]; int *q = new int[h+1]; p[w] = INT_MAX; q[h] = INT_MAX; for(int i=0; i<w; ++i) cin>>p[i]; for(int i=0; i<h; ++i) cin>>q[i]; int res = cal(w, h, p, q); delete []p; delete []q; std::cout << res << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:69:12: error: 'INT_MAX' was not declared in this scope 69 | p[w] = INT_MAX; | ^~~~~~~ a.cc:25:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 24 | #include <fenv.h> +++ |+#include <climits> 25 | using namespace std;
s133914045
p03972
C++
#include <iostream> #include <vector> #include <cstdio> #include <string> using namespace std; int main(void) { int W, H; cin >> W >> H; vector<int> p(W), q(H); for(int i = 0; i < W; i++) cin >> p[i]; for(int i = 0; i < H; i++) cin >> q[i]; sort(p.begin(), p.end()); sort(q.begin(), q.end()); p.push_back(1000000000); q.push_back(1000000000); int i = 0, j = 0, sum = 0, p_rest = H+1, q_rest = W+1; while(i != W || j != H) { if(p[i] <= q[j]) { sum += p[i]*p_rest; q_rest--; i++; } else { sum += q[j]*q_rest; p_rest--; j++; } } cout << sum << endl; return 0; }
a.cc: In function 'int main()': a.cc:16:3: error: 'sort' was not declared in this scope; did you mean 'short'? 16 | sort(p.begin(), p.end()); | ^~~~ | short
s979761376
p03972
C++
#include <iostream> #include <algorithm> #include <vector> #define MAX 100010 using namespace std; int w,h; vector<pair<int,int> > v; long long a,b; long long ans; int main() { cin >> w >> h; for (int i = 0; i < w; i++) { int p; cin >> p; v.push_back(make_pair(p,0)); } for (int i = 0; i < h; i++) { int p; cin >> p; v.push_back(make_pair(p,1)); } sort(v.begin(),v.end()); for (auto p : v) { long long c = p.first; if (p.second == 0) { ans += c * (w - max(b-1,0)); a++; } else { ans += c * (w - max(a-1,0)); b++; } } cout << ans << '\n'; }
a.cc: In function 'int main()': a.cc:31:32: error: no matching function for call to 'max(long long int, int)' 31 | ans += c * (w - max(b-1,0)); | ~~~^~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:31:32: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 31 | ans += c * (w - max(b-1,0)); | ~~~^~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:31:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 31 | ans += c * (w - max(b-1,0)); | ~~~^~~~~~~ a.cc:34:32: error: no matching function for call to 'max(long long int, int)' 34 | ans += c * (w - max(a-1,0)); | ~~~^~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:34:32: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 34 | ans += c * (w - max(a-1,0)); | ~~~^~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:34:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 34 | ans += c * (w - max(a-1,0)); | ~~~^~~~~~~
s653780158
p03972
C++
#include <iostream> #include <vector> #include <string> #include <cmath> #include <algorithm> using namespace std; long long int par[10000000010] = {0}; long long int rrank[10000000010] = {0}; void init(long long int n, long long int par[], long long int rank[]) { for (int i = 0; i < n; i++) { par[i] = i; rank[i] = 0; } } int find(long long int x, long long int par[]) { if (par[x] == x) { return x; } else { return par[x] = find(par[x], par); } } void unite(long long int x, long long int y, long long int par[], long long int rank[]) { x = find(x, par); y = find(y, par); if (x == y) { return ; } if (rank[x] < rank[y]) { par[x] = y; } else { par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } bool same(long long int x, long long int y, long long int par[]) { return find(x, par) == find(y, par); } struct edge { long long int u, v, cost; }; bool comp(const edge& e1, const edge& e2) { return e1.cost < e2.cost; } vector<edge> es; long long int V, E; long long int kruskal(long long int par[], long long int rank[]) { sort(es.begin(), es.end(), comp); init(V, par, rank); long long int res = 0; for (long long int i = 0; i < E; i++) { edge e = es[i]; if (same(e.u, e.v, par)) { unite(e.u, e.v, par, rank); res += e.cost; } } return res; } int main() { long long int w, h; cin >> w >> h; V = w*h; E = (w-1)*h+w*(h-1); vector<long long int> p(w); vector<long long int> q(h); for (long long int i = 0; i < w; i++) { cin >> p[i]; } for (long long int i = 0; i < h; i++) { cin >> q[i]; } for (long long int i = 0; i < w-1; i++) { for (long long int j = 0; j < h; j++) { edge e; e.u = i*w+j; e.v = (i+1)*w+j; e.cost = p[i]; es.push_back(e); } } for (long long int i = 0; i < h-1; i++) { for (long long int j = 0; j < w; j++) { edge e; e.u = j*w+i; e.v = j*w+i+1; e.cost = q[i]; es.push_back(e); } } cout << kruskal(par, rrank) << endl; return 0; }
/tmp/ccNEyOAj.o: in function `kruskal(long long*, long long*)': a.cc:(.text+0x26c): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccNEyOAj.o a.cc:(.text+0x27e): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccNEyOAj.o a.cc:(.text+0x2a5): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccNEyOAj.o a.cc:(.text+0x2d8): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccNEyOAj.o a.cc:(.text+0x341): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccNEyOAj.o /tmp/ccNEyOAj.o: in function `main': a.cc:(.text+0x398): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccNEyOAj.o a.cc:(.text+0x3c2): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccNEyOAj.o a.cc:(.text+0x523): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccNEyOAj.o a.cc:(.text+0x5d1): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccNEyOAj.o a.cc:(.text+0x606): relocation truncated to fit: R_X86_64_PC32 against symbol `rrank' defined in .bss section in /tmp/ccNEyOAj.o /tmp/ccNEyOAj.o: in function `__static_initialization_and_destruction_0()': a.cc:(.text+0x6c7): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s948428898
p03972
C++
#include <iostream> #include <string> #include <algorithm> #include <map> #include <vector> #include <limit.h> using namespace std; #define debug(x) cout<<#x<<": "<<x<<endl #define rep(i,a,b) for(int i=a;i<b;i++) #define PB push_back #define SORT(v) sort(v.begin(), v.end()) #define REVSORT(v) sort(v.begin(), v.end(), std::greater<int>()) typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(false); int w, h; int tmp; cin >> w >> h; vector <ll>p; vector <ll>q; ll ans = 0; rep(i, 0, w){ cin >> tmp; p.PB(tmp); } rep(i, 0, h){ cin >> tmp; q.PB(tmp); } int m = INT_MAX; int n = INT_MAX; rep(i, 0, h){ if (m > p[i])m = p[i]; } rep(i, 0, w){ if (n > q[i])n = q[i]; } if (m*w > n*h){ ans = m*(w-1); } else{ ans = n*(h-1); } rep(i, 0, h){ ans += p[i]; } rep(i, 0, w){ ans += q[i]; } cout << ans << endl; return 0; }
a.cc:6:10: fatal error: limit.h: No such file or directory 6 | #include <limit.h> | ^~~~~~~~~ compilation terminated.
s826094943
p03972
C++
#include <vector> #include <queue> #include <algorithm> #include <iostream> #include <string> #include <tuple> #include <set> #include <map> #include <complex> #include <iomanip> #include <cmath> #include <complex> using namespace std; typedef long long ll; typedef int long long; typedef pair<ll,ll> P; typedef ll Weight; struct Edge { int src, dst; Weight weight; Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) { } }; bool operator < (const Edge &e, const Edge &f) { return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!! e.src != f.src ? e.src < f.src : e.dst < f.dst; } typedef vector<Edge> Edges; typedef vector<Edges> Graph; typedef vector<Weight> Array; typedef vector<Array> Matrix; pair<Weight, Edges> minimumSpanningTree(const Graph &g, ll r = 0) { int n = g.size(); Edges T; Weight total = 0; vector<bool> visited(n); priority_queue<Edge> Q; Q.push( Edge(-1, r, 0) ); while (!Q.empty()) { Edge e = Q.top(); Q.pop(); if (visited[e.dst]) continue; T.push_back(e); total += e.weight; visited[e.dst] = true; for(auto f=g[e.dst].begin();f!=g[e.dst].end();f++) if (!visited[f->dst]) Q.push(*f); } return pair<Weight, Edges>(total, T); } int W,H; ll iti(ll y, ll x){ return (W+1)*y + x; } signed int main(){ cin >> W >> H; Graph g((W+1)*(H+1)); // (W+1)*y + x for(int i=0;i<W;i++){ ll p; cin >> p; for(int y=0;y<=H;y++){ g[iti(y,i)].push_back(Edge(iti(y,i), iti(y,i+1), p)); g[iti(y,i+1)].push_back(Edge(iti(y,i+1), iti(y,i), p)); } } for(int i=0;i<H;i++){ ll q; cin >> q; for(int x=0;x<=W;x++){ g[iti(i,x)].push_back(Edge(iti(i,x), iti(i+1,x), q)); g[iti(i+1,x)].push_back(Edge(iti(i+1,x), iti(i,x), q)); } } ll ans =0; Edges e; tie(ans,e) = minimumSpanningTree(g); cout << ans << endl; return 0; }
a.cc:15:18: error: declaration does not declare anything [-fpermissive] 15 | typedef int long long; | ^~~~
s926376201
p03972
C++
#include <bits/stdc++.h> #include<iostream> #include<cstdio> #include<vector> #include<queue> #include<map> #include<cstring> #include<string> #include <math.h> #include<algorithm> // #include <boost/multiprecision/cpp_int.hpp> #include<functional> #define int long long #define inf 1000000007 #define pa pair<int,int> #define ll long long #define pal pair<ll,ll> #define ppa pair<int,pa> #define mp make_pair #define EPS (1e-10) #define equals(a,b) (fabs((a)-(b))<EPS) using namespace std; class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y) {} Point operator + (Point p) {return Point(x+p.x,y+p.y);} Point operator - (Point p) {return Point(x-p.x,y-p.y);} Point operator * (double a) {return Point(x*a,y*a);} Point operator / (double a) {return Point(x/a,y/a);} double absv() {return sqrt(norm());} double norm() {return x*x+y*y;} bool operator < (const Point &p) const{ return x != p.x ? x<p.x: y<p.y; } bool operator == (const Point &p) const{ return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS; } }; typedef Point Vector; struct Segment{ Point p1,p2; }; double hen(Vector a){ if(fabs(a.x)<EPS && a.y>0) return acos(0); else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0); else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0); else if(fabs(a.y)<EPS && a.x>0) return 0.0; else if(a.y>0) return acos(a.x/a.absv()); else return 2*acos(0)+acos(-a.x/a.absv()); } double dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; } double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; //----------------kokomade temple------------ vector<pa> ve; signed main(){ int w,h; cin>>w>>h; int ans=0,tate=0,yoko=0; int z; for(int i=0;i<w;i++){ cin>>z; ve.push_back(mp(z,0)) } for(int i=0;i<h;i++){ cin>>z; ve.push_back(mp(z,1)) } sort(ve.begin(),ve.end()); for(int i=0;i<w+h;i++){ pa zz=ve[i]; if(zz.second==0){ ans += zz.first*(h+1-yoko); tate++; } else{ ans += zz.first*(w+1-tate); yoko++; } } cout<<ans<<endl; return 0; } //printf("%.10f\n",ans);
a.cc: In function 'int main()': a.cc:77:38: error: expected ';' before '}' token 77 | ve.push_back(mp(z,0)) | ^ | ; 78 | } | ~ a.cc:81:38: error: expected ';' before '}' token 81 | ve.push_back(mp(z,1)) | ^ | ; 82 | } | ~
s318171941
p03972
C++
#include <cstdio> #include <string> using namespace std; int n,m,i,c,d,a[200200]; long long x[2],r; int main() { for (i=0; i<2; i++) x[i]=1; scanf("%d%d",&n,&m); for (i=0; i<n; i++) { scanf("%d",&a[i]); a[i]*=2; } for (i=0; i<m; i++) { scanf("%d",&a[n+i]); a[n+i]=a[n+i]*2+1; } n+=m; sort(a,a+n); for (i=n-1; i>=0; i--) { c=a[i]/2; d=a[i]%2; r+=x[d]*c; x[1-d]++; } printf("%lld\n",r); return 0; }
a.cc: In function 'int main()': a.cc:18:3: error: 'sort' was not declared in this scope; did you mean 'short'? 18 | sort(a,a+n); | ^~~~ | short
s600405500
p03973
C
#include <bits/stdc++.h> using namespace std; #define B begin() #define E end() #define F first #define S second #define pub push_back #define mkp make_pair #define migmig ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) typedef long double ld; typedef long long ll; typedef vector<ll> vll; typedef map<ll,ll> mll; const ll N=3e5+5; ll n, k, sum, l, x, m, i, a[N], ans; int main(){ cin>> n; for(ll i=0; i<n; i++){ cin>> a[i]; } x = 1; for(ll i=0; i<n; i++){ ans += ( a[i] / x == 1 ? 0 : a[i] / x ); x = max(x, (a[i] % x == 0 ? x : a[i] % x) + 1); } cout<<ans; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s705814077
p03973
C++
#include <vector> #include <iostream> #include <algorithm> #include <utility> #include <set> #include <map> #include <cmath> using namespace std; template<typename T, typename S> istream& operator >> (istream& is, pair<T, S>& p) { is >> p.first >> p.second; return is; } template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& x : v) { is >> x; } return is; } template<typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (auto& x : v) { os << x << " "; } os << "\n"; return os; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifdef _DEBUG freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n; cin >> n; vector<int64_t> a(n); cin >> a; int64_t ans = 0, cur_bar = 0; for (auto x : a) { if (x <= cur_bar + 1) { cur_bar = max(x, cur_bar); } else { ans += (x - 1) / (cur_bar + 1); cur_bar = max(cur_bar, 1ll); } } cout << ans; }
a.cc: In function 'int main()': a.cc:53:26: error: no matching function for call to 'max(int64_t&, long long int)' 53 | cur_bar = max(cur_bar, 1ll); | ~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:62, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:53:26: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 53 | cur_bar = max(cur_bar, 1ll); | ~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:53:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 53 | cur_bar = max(cur_bar, 1ll); | ~~~^~~~~~~~~~~~~~
s113724421
p03973
C++
15 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 15 | ^~
s351445712
p03973
C++
#include <iostream> #include <iomanip> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <utility> #include <string> #include <cmath> #include <cstdlib> #include <cstring> #include <deque> #include <numeric> using namespace std; typedef uint64_t u64; typedef int64_t s64; typedef uint32_t u32; typedef int32_t s32; typedef vector<s32> vs32; typedef vector<u32> vu32; typedef vector<s64> vs64; typedef vector<u64> vu64; const double PI=3.14159265358979323846; #define MAX(x, y) ((x) < (y) ? (y) : (x)) #define MIN(x, y) ((x) > (y) ? (y) : (x)) #define rep(i, N) for(int i = 0; i < N; ++i) #define CEIL(x, y) (((x) + (y) - 1) / (y)) #define MOD 1000000007ULL #define IN(l, r, x) ((l) <= (x) && (x) < (r)) int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vs64 a(n); rep (i, n) cin >> a[i]; s64 ans = 0; s64 p = 0; rep (i, n) { // cout << "p = " << p << "\n"; if (a[i] <= p + 1) { p = a[i]; // cout << a[i] << " -> " << a[i] << "\n"; // cout << "ans += 0\n"; } else { ans += (a[i] - 1) / (p + 1); // cout << a[i] << " -> " << 1 << "\n"; // cout << "ans += " << (a[i] - 1) / (p + 1) << "\n"; p = max(p, 1ll); // a[i] = 1; } // rep (j, n) cout << a[j] << " "; // cout << "\n"; } cout << ans << "\n"; return 0; }
a.cc:20:9: error: 'uint64_t' does not name a type 20 | typedef uint64_t u64; | ^~~~~~~~ a.cc:17:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 16 | #include <numeric> +++ |+#include <cstdint> 17 | a.cc:22:9: error: 'uint32_t' does not name a type 22 | typedef uint32_t u32; | ^~~~~~~~ a.cc:22:9: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:25:16: error: 'u32' was not declared in this scope; did you mean 's32'? 25 | typedef vector<u32> vu32; | ^~~ | s32 a.cc:25:19: error: template argument 1 is invalid 25 | typedef vector<u32> vu32; | ^ a.cc:25:19: error: template argument 2 is invalid a.cc:27:16: error: 'u64' was not declared in this scope; did you mean 's64'? 27 | typedef vector<u64> vu64; | ^~~ | s64 a.cc:27:19: error: template argument 1 is invalid 27 | typedef vector<u64> vu64; | ^ a.cc:27:19: error: template argument 2 is invalid a.cc: In function 'int main()': a.cc:67:20: error: no matching function for call to 'max(s64&, long long int)' 67 | p = max(p, 1ll); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:67:20: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 67 | p = max(p, 1ll); | ~~~^~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:8: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:67:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 67 | p = max(p, 1ll); | ~~~^~~~~~~~
s199154274
p03973
C++
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> #include <bits/stdc++.h> using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) #define pll pair<ll,ll> #define pint pll using ll = long long; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; int main(){ int n; cin >> n; long a[n]; rep(i,n)cin >> a[i]; long ans=a[0]-1; long x=2; REP(i,1,n){ if(a[i]==x){ x=a[i]+1; continue; } ans+=max((a[i]+x-1)/x-1,0L) } cout << ans << endl; return 0;}
a.cc: In function 'int main()': a.cc:40:32: error: expected ';' before '}' token 40 | ans+=max((a[i]+x-1)/x-1,0L) | ^ | ; 41 | } | ~
s812600356
p03973
C++
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> #include <bits/stdc++.h> using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) #define pll pair<ll,ll> #define pint pll using ll = long long; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; int main(){ int n; cin >> n; long a[n]; rep(i,n)cin >> a[i]; long ans=a[0]-1; long x=2; REP(i,1,n){ if(a[i]==x){ x=a[i]+1; continue; } ans+=max((a[i]+x-1)/x-1,0LL) } cout << ans << endl; return 0;}
a.cc: In function 'int main()': a.cc:40:13: error: no matching function for call to 'max(long int, long long int)' 40 | ans+=max((a[i]+x-1)/x-1,0LL) | ~~~^~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:40:13: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 40 | ans+=max((a[i]+x-1)/x-1,0LL) | ~~~^~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:40:13: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 40 | ans+=max((a[i]+x-1)/x-1,0LL) | ~~~^~~~~~~~~~~~~~~~~~~~
s427564414
p03973
C++
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> #include <bits/stdc++.h> using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) #define pll pair<ll,ll> #define pint pll using ll = long long; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; int main(){ int n; cin >> n; ll a[n]; rep(i,n)cin >> a[i]; ll ans=a[0]-1; ll x=2; REP(i,1,n){ if(a[i]==x){ x=a[i]+1; continue; } ans+=max((a[i]+x-1)/x-1,0LL) } cout << ans << endl; return 0;}
a.cc: In function 'int main()': a.cc:40:33: error: expected ';' before '}' token 40 | ans+=max((a[i]+x-1)/x-1,0LL) | ^ | ; 41 | } | ~
s589990463
p03973
C++
using namespace std; typedef long long ll; int main(){ int N; cin>> N; vector<ll> A(N); for(int i = 0; i < N; i++){ cin >> A[i];} sort(A.begin(),A.end()); vector<ll> kind; vector<ll> cnt; int head = 0; int tail = 0; while( head < N && tail < N){ while( A[head] == A[tail]){ tail++;} kind.push_back(A[head]); cnt.push_back(tail-head); head = tail; } vector<ll> ans; ll now = 1; //現在の数字 ll sum = 0; //これまでの和 int itr = 0; //kindのどこまで見たか const int m = (int)kind.size(); while( itr < m){ while( sum < kind[itr]-1){ sum++; ans.push_back(now);} // sum == kind[itr]-1まで足し続ける. while( sum+now == kind[itr] && itr < m ){ now++; itr++;} ans.push_back(now); sum += now; now = 1; } for(auto ne : ans){ cout << ne << " " ;} cout<< endl; return 0; }
a.cc: In function 'int main()': a.cc:7:9: error: 'cin' was not declared in this scope 7 | int N; cin>> N; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | a.cc:9:3: error: 'vector' was not declared in this scope 9 | vector<ll> A(N); | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | a.cc:9:12: error: expected primary-expression before '>' token 9 | vector<ll> A(N); | ^ a.cc:9:14: error: 'A' was not declared in this scope 9 | vector<ll> A(N); | ^ a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'short'? 13 | sort(A.begin(),A.end()); | ^~~~ | short a.cc:15:12: error: expected primary-expression before '>' token 15 | vector<ll> kind; vector<ll> cnt; | ^ a.cc:15:14: error: 'kind' was not declared in this scope 15 | vector<ll> kind; vector<ll> cnt; | ^~~~ a.cc:15:29: error: expected primary-expression before '>' token 15 | vector<ll> kind; vector<ll> cnt; | ^ a.cc:15:31: error: 'cnt' was not declared in this scope; did you mean 'int'? 15 | vector<ll> kind; vector<ll> cnt; | ^~~ | int a.cc:30:12: error: expected primary-expression before '>' token 30 | vector<ll> ans; | ^ a.cc:30:14: error: 'ans' was not declared in this scope 30 | vector<ll> ans; | ^~~ a.cc:49:23: error: 'cout' was not declared in this scope 49 | for(auto ne : ans){ cout << ne << " " ;} | ^~~~ a.cc:49:23: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:51:3: error: 'cout' was not declared in this scope 51 | cout<< endl; | ^~~~ a.cc:51:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:51:10: error: 'endl' was not declared in this scope 51 | cout<< endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 |
s453207906
p03973
C++
ok
a.cc:1:1: error: 'ok' does not name a type 1 | ok | ^~
s479627330
p03973
C++
ok
a.cc:1:1: error: 'ok' does not name a type 1 | ok | ^~
s171114284
p03973
C++
include <iostream> #include <cstdio> #include <cstring> using namespace std; const int MAXN=100005; int n,p=1; int main() { cin>>n; long long ans=0; for(int i=1;i<=n;++i){ int x; scanf("%d",&x); if(x<p)continue; if(x==p)++p; else{ if(x%p==0)ans+=x/p-1; else ans+=x/p; } if(p==1)++p; } cout<<ans<<endl; return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ a.cc: In function 'int main()': a.cc:9:3: error: 'cin' was not declared in this scope 9 | cin>>n; | ^~~ a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include <cstring> +++ |+#include <iostream> 4 | using namespace std; a.cc:22:3: error: 'cout' was not declared in this scope 22 | cout<<ans<<endl; | ^~~~ a.cc:22:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:22:14: error: 'endl' was not declared in this scope 22 | cout<<ans<<endl; | ^~~~ a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 3 | #include <cstring> +++ |+#include <ostream> 4 | using namespace std;
s991870044
p03973
C++
#include <iostream> #include <math.h> #include <string> #include <algorithm> using namespace std; int main(){ long long n,i,q; long long cnt = 0; cin >> n; long long a[100000]; for (long long i = 0; i < n; i++){ cin >> a[i]; } if (a[0]>1){ cnt+=a[0]-1; } i = 1; q = 1; while (i<n){ if (a[i] >(q+1)){ cnt += ((a[i] - 1) / (q+1)); a[i] = 1; } else if((q+1)==a[i]){ q = a[i]; } i++; } //cnt++; cout << cnt << endl; return 0; } #include <iostream> #include <math.h> #include <string> #include <algorithm> using namespace std; int main(){ long long n,i,q; long long cnt = 0; cin >> n; long long a[100000]; for (long long i = 0; i < n; i++){ cin >> a[i]; } if (a[0]>1){ cnt+=a[0]-1; } i = 1; q = 1; while (i<n){ if (a[i] >(q+1)){ cnt += ((a[i] - 1) / (q+1)); a[i] = 1; } else if((q+1)==a[i]){ q = a[i]; } i++; } //cnt++; cout << cnt << endl; return 0; } Submission
a.cc:41:5: error: redefinition of 'int main()' 41 | int main(){ | ^~~~ a.cc:7:5: note: 'int main()' previously defined here 7 | int main(){ | ^~~~ a.cc:69:1: error: 'Submission' does not name a type 69 | Submission | ^~~~~~~~~~
s354542057
p03973
C++
N = int(input()) A = [int(input()) for i in range(N)] V = 1 ans = 0 for i in range(N): #print(V, ans) if(A[i] > V): t = (A[i]-1)//V ans += t A[i] -= V*t if(A[i]+1 > V): A[i] = 1 V = max(V,A[i]+1) print(ans)
a.cc:6:6: error: invalid preprocessing directive #print 6 | #print(V, ans) | ^~~~~ a.cc:1:1: error: 'N' does not name a type 1 | N = int(input()) | ^
s228916347
p03973
C++
#include <iostream> #include <vector> using namespace std; int main(){ int n,cnt,cmin; cmin=2; cnt=0; vector<int> a; cin>>n; for(int i=0;i<n;i++){ int c; cin>>c; a.push_back(c); } int i=0; int done =0; cnt+=a[i]-1; a[i]=1; while(i<n){ cout<<i<<" "<<done<<endl; if(a[i]>cmin){ cnt+=a[i]/cmin; a[i]=1; done=i+1; i=done; } }else if(a[i]==cmin){ cmin++; done=i+1; i=done; }else{ i++; } } cout<<cnt<<endl; }
a.cc: In function 'int main()': a.cc:29:10: error: 'else' without a previous 'if' 29 | }else if(a[i]==cmin){ | ^~~~ a.cc: At global scope: a.cc:37:5: error: 'cout' does not name a type 37 | cout<<cnt<<endl; | ^~~~ a.cc:38:1: error: expected declaration before '}' token 38 | } | ^
s205924183
p03973
Java
import java.util.*; public class Main1 { public static void main(String[] args) throws InterruptedException{ Scanner sc = new Scanner(System.in); int n_customer = sc.nextInt(); long sold = sc.nextInt() -1; int i = 1; int price = 2; if(n_customer > 1){ while(true){ int money = sc.nextInt(); if(money < price) i++; else if(money == price){ price++; i++; }else{ if(money % price == 0){ sold += money / price -1; }else{ sold += money / price; } i++; } if(i == n_customer) break; } } System.out.println(sold); } }
Main.java:2: error: class Main1 is public, should be declared in a file named Main1.java public class Main1 { ^ 1 error
s728245922
p03973
Java
import java.util.*; public class Main1 { public static void main(String[] args) throws InterruptedException{ Scanner sc = new Scanner(System.in); int n_customer = sc.nextInt(); long sold = sc.nextInt() -1; int i = 1; int price = 2; if(n_customer > 1){ while(true){ int money = sc.nextInt(); if(money < price) i++; else if(money == price){ price++; i++; }else{ if(money % price == 0){ sold += money / price -1; }else{ sold += money / price; } i++; } if(i == n_customer) break; } }else{ sold++; } System.out.println(sold); } }
Main.java:2: error: class Main1 is public, should be declared in a file named Main1.java public class Main1 { ^ 1 error
s471717133
p03973
Java
import java.util.*; public class Main1 { public static void main(String[] args) throws InterruptedException{ Scanner sc = new Scanner(System.in); int n_customer = sc.nextInt(); long sold = sc.nextInt() -1; int i = 1; int price = 2; while(true){ int money = sc.nextInt(); if(money < price) i++; else if(money == price){ price++; i++; }else{ if(money % price == 0){ sold += money / price -1; }else{ sold += money / price; } i++; } if(i == n_customer-1) break; } System.out.println(sold); } }
Main.java:2: error: class Main1 is public, should be declared in a file named Main1.java public class Main1 { ^ 1 error
s201794904
p03973
Java
import java.util.*; public class Main1 { public static void main(String[] args) throws InterruptedException{ Scanner sc = new Scanner(System.in); int n_customer = sc.nextInt(); long sold = sc.nextInt() -1; int i = 1; int price = 2; while(true){ int money = sc.nextInt(); if(money < price) i++; else if(money == price){ price++; i++; }else{ if(money % price == 0){ sold += money / price -1; }else{ sold += money / price; } i++; } if(i == n_customer) break; } System.out.println(sold); } }
Main.java:2: error: class Main1 is public, should be declared in a file named Main1.java public class Main1 { ^ 1 error
s404608115
p03973
C++
#include <iostream> #include <vector> using namespace std; int main(){ int n,cnt,cmin; cmin=2; cnt=0; vector<int> a; cin>>n; for(int i=0;i<n;i++){ int c; cin>>c; a.push_back(c); } int i=0; int done =0; cnt+=a[i]-1; a[i]=1; while(i<n){ if(a[i]>cmin){ if(a[i]>2*cmin){ a[i]-=cmin; cnt++; i=done }else{ a[i]=1; cnt++; done=i+1; i=done; } }else if(a[i]==cmin){ cmin++; done=i+1; i=done; }else{ i++; } } cout<<cnt<<endl; }
a.cc: In function 'int main()': a.cc:26:23: error: expected ';' before '}' token 26 | i=done | ^ | ; 27 | }else{ | ~
s193482268
p03973
C++
#include <iostream> #include <vector> using namespace std; int main(){ int n,cnt,cmin; cmin=2; cnt=0; vector<int> a; cin>>n; for(int i=0;i<n;i++){ int c; cin>>c; a.push_back(c); } int i=0; cnt+=a[i]-1; a[i]=1; while(i<n){ if(a[i]>cmin){ if(a[i]>2*cmin){ a[i]-=cmin; cnt++; i=done; continue; }else{ a[i]=1; cnt++; done=i+1; i=done; continue; } }else if(a[i]==cmin){ cmin++; done=i+1; i=done; continue; }else{ i++; } } cout<<cnt<<endl; }
a.cc: In function 'int main()': a.cc:25:19: error: 'done' was not declared in this scope 25 | i=done; | ^~~~ a.cc:30:17: error: 'done' was not declared in this scope 30 | done=i+1; | ^~~~ a.cc:36:13: error: 'done' was not declared in this scope 36 | done=i+1; | ^~~~
s519384344
p03973
C
#include <stdio.h> int main(void) { int n,i,j long max,cnt ; long a[100000] ; max = 1; cnt = 0 ; scanf("%d",&n) ; for(i=0 ; i<n ; i++){ scanf("%d", &a[i]) ; } for(i=0; i<n ; i++){ while(a[i] > max){ if(a[i] - max == max){ a[i] = 1 ; cnt++ ; break ; } a[i] = a[i] - max ; cnt++ ; } if(a[i] >= max) max++ ; } printf("%d", cnt) ; return 0; }
main.c: In function 'main': main.c:6:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'long' 6 | long max,cnt ; | ^~~~ main.c:9:9: error: 'max' undeclared (first use in this function) 9 | max = 1; | ^~~ main.c:9:9: note: each undeclared identifier is reported only once for each function it appears in main.c:10:9: error: 'cnt' undeclared (first use in this function); did you mean 'int'? 10 | cnt = 0 ; | ^~~ | int
s769667851
p03973
C++
#include<iostream> #include <stdio.h> #include <stdlib.h> #include <time.h> using namespace std; int count = 0; int NextCustomer(int[] C,int N, int pos, int CP, int price) { if (C > price) { count++; return CP-price; } else if (C == price || pos = N-1) return CP; else C[pos+1] = NextCustomer(C, N, pos+1, C[pos+1], price); } int main() { unsigned seed; seed = (unsigned)time(NULL); srand(seed); int N; cin >> N; int A[N]; for (int i=0; i<N; i++) cin >> A[i]; bool stop = false; while (!stop) { int Max = A[0]; for (int i=0; i<N-1; i++) { if (A[i+1] > A[i]) Max = A[i+1]; } int P = rand()%Max; while (P=A[0]) P=rand()%Max; if (A[0] > P) { A[0] =- P; count++ if (A[0] == 1) stop = true; } else A[0] = NextCustomer(A, N, 1, A[1], P); for (int i=0; i<N-1; i++) { if (A[i]==1) stop = true; } } cout << count <<endl; return 0; }
a.cc:10:24: error: expected ',' or '...' before 'C' 10 | int NextCustomer(int[] C,int N, int pos, int CP, int price) | ^ a.cc: In function 'int NextCustomer(int*)': a.cc:13:13: error: 'C' was not declared in this scope 13 | if (C > price) | ^ a.cc:13:17: error: 'price' was not declared in this scope 13 | if (C > price) | ^~~~~ a.cc:16:24: error: 'CP' was not declared in this scope 16 | return CP-price; | ^~ a.cc:18:32: error: 'pos' was not declared in this scope 18 | else if (C == price || pos = N-1) | ^~~ a.cc:18:38: error: 'N' was not declared in this scope 18 | else if (C == price || pos = N-1) | ^ a.cc:19:24: error: 'CP' was not declared in this scope 19 | return CP; | ^~ a.cc: In function 'int main()': a.cc:56:32: error: expected ';' before 'if' 56 | count++ | ^ | ; 57 | if (A[0] == 1) | ~~ a.cc:61:44: error: too many arguments to function 'int NextCustomer(int*)' 61 | A[0] = NextCustomer(A, N, 1, A[1], P); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:10:5: note: declared here 10 | int NextCustomer(int[] C,int N, int pos, int CP, int price) | ^~~~~~~~~~~~
s636029173
p03973
C++
#include <iostream> #include <algorithm> #include <string> #include <stack> #include <map> #include <queue> #include <vector> using namespace std; int main() { long long int i, x, sum, n, pri, start; pri = 1; sum = 0; cin >> n; vector<int> mon(n, 0); for (i = 0; i < n; i++) { cin >> mon[i]; } start = 0; while (start < n) { for (i = start; i < n; i++) { if (mon[i] == pri) { break; } else if (mon[i] < pri) continue; else if (mon[i] % pri == 0) { sum += mon[i] / pri - 1; mon[i] = pri; } else { sum += mon[i] / pri; mon[i] = mon[i] % pri; } } while (start < n) { if (mon[start] <= pri) { pri = max(mon[start] + 1, pri); start++; } else { break; } } } cout << sum << endl; return 0; }
a.cc: In function 'int main()': a.cc:38:42: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type, long long int&)' 38 | pri = max(mon[start] + 1, pri); | ~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:38:42: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 38 | pri = max(mon[start] + 1, pri); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:38:42: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 38 | pri = max(mon[start] + 1, pri); | ~~~^~~~~~~~~~~~~~~~~~~~~
s026341353
p03973
C++
#include <iostream> #include <string> #include <algorithm> #include <stdlib.h> #include <math.h> #define ll long long using namespace std; ll a[1000000010]; ll sum = 0; int main(){ int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; } sum += a[0] - 1; ll limit = 2; // ll limit = 1; for (int i = 1; i < n; ++i) { ll tmp_limit = limit; if(a[i] == limit){ limit++; } // int tmp_limit = limit; // while(true){ // tmp_limit++; // if(a[i] % tmp_limit == a[i] % limit) // } while(a[i] > tmp_limit){ a[i] -= tmp_limit; sum++; } // if(a[i] + 1 > limit) limit = a[i] + 1; } cout << sum << endl; }
/tmp/ccguPPO7.o: in function `main': a.cc:(.text+0x6a): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccguPPO7.o a.cc:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccguPPO7.o a.cc:(.text+0xf1): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccguPPO7.o a.cc:(.text+0xfc): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccguPPO7.o a.cc:(.text+0x131): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccguPPO7.o collect2: error: ld returned 1 exit status
s221424295
p03973
C++
#include <iostream> #include <string> #include <algorithm> #include <stdlib.h> #include <math.h> #define ll long long using namespace std; int n; ll a[1000000010]; ll sum = 0; int main(){ cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; } sum += a[0] - 1; ll limit = 2; // ll limit = 1; for (int i = 1; i < n; ++i) { ll tmp_limit = limit; if(a[i] == limit){ limit++; } // int tmp_limit = limit; // while(true){ // tmp_limit++; // if(a[i] % tmp_limit == a[i] % limit) // } while(a[i] > tmp_limit){ a[i] -= tmp_limit; sum++; } // if(a[i] + 1 > limit) limit = a[i] + 1; } cout << sum << endl; }
/tmp/ccCBoiKq.o: in function `main': a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccCBoiKq.o a.cc:(.text+0x7a): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccCBoiKq.o a.cc:(.text+0xf7): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccCBoiKq.o a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccCBoiKq.o a.cc:(.text+0x13a): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccCBoiKq.o collect2: error: ld returned 1 exit status
s836102967
p03973
C++
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #define REP(i,a,b) for(int i=a;i<b;++i) #define rep(i,n) REP(i,0,n) #define ll long long #define ull unsigned ll typedef long double ld; #define ALL(a) begin(a),end(a) #define ifnot(a) if(not (a)) #define dump(x) cerr << #x << " = " << (x) << endl using namespace std; // #define int ll #ifdef _MSC_VER const bool test = true; #else const bool test = false; #endif int dx[] = { 0,1,0,-1 }; int dy[] = { 1,0,-1,0 }; #define INF (1 << 28) ull mod = (int)1e9 + 7; //..................... #define MAX (int)1e5 + 5 int N; ll A[MAX]; signed main() { cin >> N; rep(i, N) cin >> A[i]; ll cnt = 0; ll max_v = 0; rep(i, N) { if (A[i] == 2) { max_v = max(max_v,2); int tmp = 0; dump(tmp); } else { int tmp = A[i] / (max_v + 1); if (A[i] % (max_v + 1) == 0) tmp--; dump(tmp); cnt += tmp; if (max_v == 0) max_v = 1; if (tmp == 0) max_v = A[i]; } } cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:39:36: error: no matching function for call to 'max(long long int&, int)' 39 | max_v = max(max_v,2); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:4: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:39:36: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 39 | max_v = max(max_v,2); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:39:36: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 39 | max_v = max(max_v,2); | ~~~^~~~~~~~~
s669722163
p03973
C++
#include <iostream> #include <string> #include <algorithm> #include <map> #include <vector> using namespace std; #define debug(x) cout<<#x<<": "<<x<<endl #define rep(i,a,b) for(int i=a;i<b;i++) #define PB push_back #define SORT(v) sort(v.begin(), v.end()) #define REVSORT(v) sort(v.begin(), v.end(), std::greater<int>()) typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; vector<ll>a; ll tmp; ll sell = 0; ll mx = 0; bool no2 = true; cin >> n; rep(i, 0, n){ cin >> tmp; a.PB(tmp); } if (a[0] != 1){ sell += a[0] - 1; a[0] = 1; } ll mins = 2; rep(i, 1, n){ // if (a[i] == 2)no2 = false; /* if (no2){ sell+=a[i] / 2; if (a[i] % 2 == 0)sell--; a[i] = 1; }*/ else{ sell += a[i] / mins; if (a[i] % mins == 0)sell--; if (mins == a[i])mins++; a[i] = 1; } } cout << sell << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:17: error: 'else' without a previous 'if' 42 | else{ | ^~~~
s809417166
p03973
C++
#include <vector> #include <iostream> #include <utility> #include <algorithm> #include <string> #include <deque> //#include <tuple> #include <queue> #include <functional> #include <cmath> #include <iomanip> #include <map> #include <numeric> #include <list> #include <assert.h> #include <math.h> //#include <array> #include <valarray> #include <stdio.h> //#include <random> //#include <windows.h> //#pragma comment(lib, "winmm.lib") #include <algorithm> using namespace std; typedef long long ll; typedef long long int llint; typedef pair<long long int, long long int> pii; typedef pair<double, double> pdd; long long int nCm(long long int n, long long int m) { if (m == 1) { return n; } else { return n*nCm(n - 1, m - 1) / m; } } long long int npm(long long int n, long long int m) { if (m == 1) { return n; } else if (m == 0) { return 1; } else { return n*npm(n, m - 1); } } llint ketasu(llint a) {//桁数 llint k = 1; while (true) { if ((a - a % 10) / 10 == 0) { break; } ++k; a = (a - a % 10) / 10; } return k; } llint keta(llint a) {//最上位 llint b = a; while (true) { if ((a - a % 10) / 10 == 0) { break; } a = (a - a % 10) / 10; b = a; } return b; } llint keta2(llint a, llint c) {//桁数目の桁 llint b = a; for (llint i = 1; i<c; ++i) { if ((a - a % 10) / 10 == 0) { break; } a = (a - a % 10) / 10; b = a; } return b % 10; } llint pow10n(llint a) {//10^n llint s = 1; for (llint i = 0; i < a; ++i) { s *= 10; } return s; } llint hoge(llint a, llint b) { if (a%b == 0) { return a; } else { return a - a%b + b; } } llint main() { llint N; cin >> N; vector<llint> money(N); llint nedan = 2; for (llint i = 0; i < N; ++i) { cin >> money[i]; } llint kosuu = money[0]-1; for (llint i = 1; i < N; ++i) { if (money[i] != nedan ) { kosuu += hoge(money[i], nedan) / nedan - 1; } else { nedan++; } } cout << kosuu << endl; }
a.cc:107:1: error: '::main' must return 'int' 107 | llint main() | ^~~~~
s779217205
p03973
Java
import java.util.Scanner; public class codefes2016bc { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int a[] = new int[N]; int nowp = 1; for (int i = 0; i < a.length; i++) { a[i] = scanner.nextInt(); } long ans = 0; for (int i = 0; i < a.length; i++) { // System.out.println("a[" + i + ":" + a[i]); // System.out.println("po:" + nowp); if (a[i] == nowp) { nowp++; // System.out.println("nowp++"); continue; } if (a[i] < nowp) { // System.out.println(ans); continue; } // System.out.println(ans + a[i] / nowp - 1); if (a[i] % nowp == 0 || nowp == 1) { ans = ans + a[i] / nowp-1; if (nowp == 1) { nowp++; } } else { ans = ans + a[i] / nowp; } } System.out.println(ans); } }
Main.java:4: error: class codefes2016bc is public, should be declared in a file named codefes2016bc.java public class codefes2016bc { ^ 1 error
s237019745
p03973
C++
#include <iostream> #include <string> #include <algorithm> #include <map> #include <vector> using namespace std; #define debug(x) cout<<#x<<": "<<x<<endl #define rep(i,a,b) for(int i=a;i<b;i++) #define PB push_back #define SORT(v) sort(v.begin(), v.end()) #define REVSORT(v) sort(v.begin(), v.end(), std::greater<int>()) typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; vector<ll>a; ll tmp; ll sell = 0; ll mx = 0; bool no2 = true; cin >> n; rep(i, 0, n){ cin >> tmp; a.PB(tmp); } if (a[0] != 1){ sell += a[0] - 1; a[o] = 1; } rep(i, 1, n){ if (a[i] == 2)no2 == false; if (no2){ sell+=a[i] / 2; a[i] = 1; } else{ sell += a[i] / 3; a[i] = 1; } } cout << sell << endl; return 0; }
a.cc: In function 'int main()': a.cc:32:19: error: 'o' was not declared in this scope 32 | a[o] = 1; | ^
s896259523
p03973
C++
// Standard I/O #include <iostream> #include <sstream> #include <cstdio> // Standard Library #include <cstdlib> #include <cstring> #include <ctime> #include <cmath> // Template Class #include <complex> #include <string> #include <vector> #include <list> #include <set> #include <map> #include <queue> #include <stack> // Container Control #include <algorithm> using namespace std; #define rep( i, n ) for( int i = 0; i < n; ++i ) #define irep( i, n ) for( int i = n-1; i >= 0; --i ) #define reep( i, s, n ) for ( int i = s; i < n; ++i ) #define ireep( i, n, s ) for ( int i = n-1; i >= s; --i ) #define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr) #define mp make_pair #define pb push_back #define eb emplace_back #define all( v ) v.begin(), v.end() #define fs first #define sc second #define vc vector // for visualizer.html double SCALE = 1.0; double OFFSET_X = 0.0; double OFFSET_Y = 0.0; #define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << "," \ << SCALE*(y) + OFFSET_Y << "," \ << SCALE*(a) + OFFSET_X << "," \ << SCALE*(b) + OFFSET_Y << ")" << endl; #define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << "," \ << SCALE*(y) + OFFSET_Y << "," \ << SCALE*(r) << ")" << endl; typedef long long ll; typedef complex<double> Point; typedef pair<int, int> pii; typedef pair<int, pii> ipii; typedef vector<int> vi; typedef vector<double> vd; typedef vector< vector<int> > vii; typedef vector< vector<double> > vdd; typedef vector<int>::iterator vi_itr; const int IINF = 1 << 28; const double INF = 1e30; const double EPS = 1e-10; const double PI = acos(-1.0); // Direction : L U R D const int dx[] = { -1, 0, 1, 0}; const int dy[] = { 0, -1, 0, 1 }; int main() { int N; int A[100000]; cin >> N; rep(i, N) cin >> A[i]; ll min_val = 1, ans = 0; rep(i, N){ ll c = (A[i]-1)/min_val; ans += c; if( c != 0 ){ if( min_val == 1 ){ A[i] -= c * min_val; } else{ A[i] -= (c-1)*min_val; A[i] = min_val-1; } } min_val = max(A[i]+1, min_val); // rep(j, N){ // cout << A[j] << " "; // } // cout << endl; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:92:30: error: no matching function for call to 'max(int, ll&)' 92 | min_val = max(A[i]+1, min_val); | ~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:92:30: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 92 | min_val = max(A[i]+1, min_val); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:20: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:92:30: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 92 | min_val = max(A[i]+1, min_val); | ~~~^~~~~~~~~~~~~~~~~
s357203159
p03973
C++
#include <iostream> #include <algorithm> #include <queue> #include <set> #include <cstdlib> using namespace std; typedef long long int ll; bool debug = false; #define show(x) if (debug) {cout << "" # x << " = " << x << endl;} #define rep(x, a, b) for (int x = a; x < b; x++) int main() { ll n; cin >> n; vector<ll> a(n, 0); rep (i, 0, n) { cin >> a[i]; } ll sum = 0; ll low = 1; rep(i, 0, n) { show(low); if (a[i] <= low) { low = max(a[i] + 1, low); } else { sum += (a[i] - low - 1) / low + 1; low = max(2, low); } } cout << sum << endl; return 0; }
a.cc: In function 'int main()': a.cc:35:16: error: no matching function for call to 'max(int, ll&)' 35 | low = max(2, low); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:35:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 35 | low = max(2, low); | ~~~^~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:35:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 35 | low = max(2, low); | ~~~^~~~~~~~
s729109517
p03973
C++
#include<iostream> #include<cstdio> #include<string> #include<algorithm> #include<cstring> #include<vector> #include<cmath> #include<queue> #include<stack> using namespace std; #define INT(x) int x; scanf("%d",&x) #define INPUT(x) scanf("%d",&x) #define REP1(x,n) for(int x = 0; x < n; x++) #define REP2(x,s,e) for(int x = s; x <= e; x++) #define RREP1(x,n) for(int x = n-1; x >= 0; x--) #define RREP2(x,s,e) for(int x = s; x >= e; x--) #define BR printf("\n") #define INF 2000000000 typedef long long ll; int main(){ int A[100000]; INT(N); REP1(i,N){ INT(a); A[i] = a; } ll sum = A[0]-1; ll mini = 1; REP2(i,1,N-1){ if (A[i] > mini + 1) { if (A[i] == mini + 2) { sum++; A[i] = 1; }else if(A[i]%(mini+1) == 0){ sum++; A[i] -= mini+2; sum += A[i]/(mini+1); A[i] %= mini+1; mini = max(mini,A[i]); }else{ sum += A[i]/(mini+1); A[i] %= mini+1; mini = max(mini,A[i]); } }else{ mini = max(mini,A[i]); } } cout << sum <<endl; return 0; }
a.cc: In function 'int main()': a.cc:42:27: error: no matching function for call to 'max(ll&, int&)' 42 | mini = max(mini,A[i]); | ~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:42:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 42 | mini = max(mini,A[i]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:42:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 42 | mini = max(mini,A[i]); | ~~~^~~~~~~~~~~ a.cc:46:27: error: no matching function for call to 'max(ll&, int&)' 46 | mini = max(mini,A[i]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:46:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 46 | mini = max(mini,A[i]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:46:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 46 | mini = max(mini,A[i]); | ~~~^~~~~~~~~~~ a.cc:50:23: error: no matching function for call to 'max(ll&, int&)' 50 | mini = max(mini,A[i]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:50:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 50 | mini = max(mini,A[i]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:50:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 50 | mini = max(mini,A[i]); | ~~~^~~~~~~~~~~
s069906565
p03973
C++
#include <bits/stdc++.h> using namespace std; int main() { long long N, tmp = 1, res = 0; cin >> N; for (int i = 0, a; i < N; i++) { cin >> a; if (a > tmp) { res += (a - 1) / tmp; tmp = max(tmp, 2); } else if(a == tmp) tmp++; } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:12:34: error: no matching function for call to 'max(long long int&, int)' 12 | tmp = max(tmp, 2); | ~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:12:34: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 12 | tmp = max(tmp, 2); | ~~~^~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:12:34: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 12 | tmp = max(tmp, 2); | ~~~^~~~~~~~
s575866498
p03973
C
#include<stdio.h> #define MAX 100001 #define max2(a,b) a<b?b:a #define max3(a,b,c) max2((max2(a,b)),c) #define max4(a,b,c,d) max3((max2(a,b)),c,d) int main(){ int i,j,k; int ans = 0; int min = 0; int tmp,t; int flag = 0; int a[MAX]; int n; scanf("%d",&n); for(i = 0;i < n;i++){ scanf("%d",&a[i]); } for(i = 0;i < n;i++){ //if(min+1 < a[i]){ t = (a[i]-1)/(min+1); ans += t; if(t)flag = 1; tmp = (a[i]-1)%(min+1)+1; if(!flag&&min < tmp){ min = tmp; } if(flag&&min<a[i])min = a[i]; flag = 0; //} } printf("%d\n",ans); return 0; }#include<stdio.h> #define MAX 100001 #define max2(a,b) a<b?b:a #define max3(a,b,c) max2((max2(a,b)),c) #define max4(a,b,c,d) max3((max2(a,b)),c,d) int main(){ int i,j,k; int ans = 0; int min = 0; int tmp,t; int flag = 0; int a[MAX]; int n; scanf("%d",&n); for(i = 0;i < n;i++){ scanf("%d",&a[i]); } for(i = 0;i < n;i++){ //if(min+1 < a[i]){ t = (a[i]-1)/(min+1); ans += t; if(t)flag = 1; tmp = (a[i]-1)%(min+1)+1; if(!flag&&min < tmp){ min = tmp; } if(flag&&min<a[i])min = a[i]; flag = 0; //} } printf("%d\n",ans); return 0; }
main.c:37:2: error: stray '#' in program 37 | }#include<stdio.h> | ^ main.c:37:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 37 | }#include<stdio.h> | ^
s705832778
p03973
C++
// In the name of God #include <iostream> #include <algorithm> #include <fstream> #include <vector> #include <deque> #include <assert.h> #include <queue> #include <stack> #include <set> #include <map> #include <stdio.h> #include <string.h> #include <utility> #include <math.h> #include <bitset> #include <iomanip> using namespace std; const int N = (int) 0, mod = (int) 0; #define int long long int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int res = 0, mx = 0; for (int i = 0; i < n; ++i) { int x; cin >> x; int use = mx + 1; int p = x; if (p <= use) { mx = max(mx, p); continue; } res += (x - 1) / use; mx = max(mx, 1); } cout << res << endl; }
a.cc: In function 'int32_t main()': a.cc:39:17: error: no matching function for call to 'max(long long int&, int)' 39 | mx = max(mx, 1); | ~~~^~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:39:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 39 | mx = max(mx, 1); | ~~~^~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:39:17: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 39 | mx = max(mx, 1); | ~~~^~~~~~~
s756056917
p03974
C++
#include <bits/stdc++.h> using namespace std; const int N = 100010; class Node { public: bool is_terminal; int cnt; Node *son[26]; Node() { is_terminal = false; cnt = 0; for (int i = 0; i < 26; i++) son[i] = nullptr; } }; class Trie { public: Node *root; Trie() { root = new Node(); } void insert(string &s) { Node *cur = root; for (char c: s) { int num = c - 'a'; if (!cur->son[num]) cur->son[num] = new Node(); cur = cur->son[num]; cur->cnt++; } cur->is_terminal = true; } }; int n, q, data[N][26][26], pref[N]; string s[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; Trie *trie = new Trie(); for (int i = 1; i <= n; i++) { cin >> s[i]; trie->insert(s[i]); } for (int i = 1; i <= n; i++) { Node *cur = trie->root; for (char c: s[i]) { int num = c - 'a'; for (int j = 0; j < 26; j++) if (j != num && cur->son[j]) data[i][num][j] += cur->son[j]->cnt; cur = cur->son[num]; if (cur->is_terminal) pref[i]++; } } cin >> q; while (q--) { int k, ans = 0; string alpha; cin >> k >> alpha; vector<int> order(26); for (int i = 0; i < 26; i++) order[alpha[i] - 'a'] = i; for (int i = 0; i < 26; i++) for (int j = 0; j < 26; j++) if (order[i] > order[j]) ans += data[k][i][j]; cout << ans + pref[k] << '\n'; } }
a.cc: In function 'int main()': a.cc:59:41: error: reference to 'data' is ambiguous 59 | data[i][num][j] += cur->son[j]->cnt; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:42:11: note: 'int data [100010][26][26]' 42 | int n, q, data[N][26][26], pref[N]; | ^~~~ a.cc:75:48: error: reference to 'data' is ambiguous 75 | ans += data[k][i][j]; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:42:11: note: 'int data [100010][26][26]' 42 | int n, q, data[N][26][26], pref[N]; | ^~~~
s865154149
p03974
C++
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> /* zet: find_by_order(k): k-stat [k > 0] order_of_key(k) : {el < k} gp_hash_table<key, val, custom_hash> rope<T>: iterators: mutable_begin, .. methods : erase, insert, substr, .. */ #define all(x) (x).begin(), (x).end() #define size(x) (int)((x).size()) #define em_back emplace_back using namespace std; using namespace __gnu_cxx; using namespace __gnu_pbds; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template<typename T> using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; struct custom_hash { static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; mt19937 eng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1e5 + 4; const int S = 4e5 + 4; const int ABC = 'z' - 'a' + 1; struct Node { vector<pii> vto; int to[ABC]; int link; int leaf; int cnt; int soon; Node() { memset(to, -1, sizeof to); link = -1; leaf = -1; cnt = 0; soon = 0; } }; int n, it; Node bor[S]; string b[N]; void add(string& s, int num) { int u = 0; for (char c : s) { int& to = bor[u].to[c - 'a']; if (to == -1) { to = ++it; } u = to; } bor[u].leaf = num; } void read() { cin >> n; for (int i = 0; i < n; ++i) { cin >> b[i]; add(b[i], i + 1); } } int h[S]; void dfs(int u, int hu) { int& res = bor[u].cnt; h[u] = hu; res += (bor[u].leaf != -1); for (int to = 0; to < ABC; ++to) { int v = bor[u].to[to]; if (v != -1) { bor[u].vto.em_back(to, v); dfs(v, hu + 1); } res += bor[v].cnt; bor[u].soon++; } if (bor[u].soon == 1) { for (int to = 0; to < ABC; ++to) { int v = bor[u].to[to]; if (v != -1) { if (bor[v].leaf != -1 || bor[v].soon > 1) { bor[u].link = v; } else { bor[u].link = bor[v].link; } break; } } } } int pos['z' + 4]; int calc(int k, string& p) { --k; int res = 0, u = 0; for (int i = 0; i < ABC; ++i) { pos[p[i]] = i; } for (int i = 0; i < size(b[k]);) { res += (bor[u].leaf != -1); if (bor[u].soon == 1) { int v = bor[u].link; i += h[v] - h[u]; u = v; continue; } int board = pos[b[k][i]]; for (pii to : bor[u].vto) { if (pos[to.first + 'a'] < board) { res += bor[to.second].cnt; } } u = bor[u].to[b[k][i] - 'a']; ++i; } return res + 1; } void solve() { read(); dfs(0, 0); int q; cin >> q; while (q--) { int k; string p; cin >> k >> p; cout << calc(k, p) << "\n"; } } int main() { ios::sync_with_stdio(0); cout.tie(0), cin.tie(0); int z = 1; /// cin >> z; while (z--) { solve(); } return 0; }
In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:4: /usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()': /usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:186:14: note: called from here 186 | struct _Alloc_hider : allocator_type // TODO check __is_final | ^~~~~~~~~~~~
s037756199
p03974
C
#include <float.h> #include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> // 内部定数 #define D_STR_MAX 100000 // 最大文字列数 #define D_CHAR_MAX 500005 // 最大文字数 #define D_CHAR_KIND 27 // 文字種類数 // 内部構造体 - グループ情報 typedef struct Grp { int miCnt; // 個数 struct Grp *mzp1Next[D_CHAR_KIND]; // 次のグループ情報 } Div; // 内部変数 static FILE *szpFpI; // 入力 static char *scp1Str[D_STR_MAX]; // 文字列 static int siSCnt; // 文字列数 static char sc1Char[D_CHAR_MAX]; // 全文字 static Grp sz1Grp[D_CHAR_MAX]; // グループ情報 static int siGCnt; // グループ情報数 // 内部変数 - テスト用 #ifdef D_TEST static int siRes; static FILE *szpFpA; static int siTNo; #endif // 1行出力 int fOutLine( char *pcpLine // <I> 1行 ) { char lc1Buf[1024]; #ifdef D_TEST lc1Buf[0] = '\0'; fgets(lc1Buf, sizeof(lc1Buf), szpFpA); if (strcmp(lc1Buf, pcpLine)) { siRes = -1; } #else printf("%s", pcpLine); #endif return 0; } // 改行カット・数値化 // 戻り値:文字数 int fCutCrLf( char *pcpStr // <I> 文字列 ) { int i; for (i = 0; pcpStr[i] != 0; i++) { if (pcpStr[i] == '\n') { pcpStr[i] = 0; break; } pcpStr[i] -= 'a' - 1; } return i; } // 実行メイン int fMain( ) { int i, j, k; char lc1Buf[1024]; // データ - 初期化 memset(sc1Char, 0, sizeof(sc1Char)); memset(sz1Grp, 0, sizeof(sz1Grp)); siGCnt = 1; // 文字列数 - 取得 fgets(lc1Buf, sizeof(lc1Buf), szpFpI); sscanf(lc1Buf, "%d", &siSCnt); // 文字列 - 取得 char *lcpWork = sc1Char; for (i = 0; i < siSCnt; i++) { fgets(lcpWork, sizeof(sc1Char), szpFpI); int liLen = fCutCrLf(lcpWork); scp1Str[i] = lcpWork; // グループ - 追加 Grp *lzpGrp = &sz1Grp[0]; for (j = 0; j <= liLen; j++) { // 新規 if (lzpGrp->mzp1Next[lcpWork[j]] == NULL) { lzpGrp->mzp1Next[lcpWork[j]] = &sz1Grp[siGCnt]; siGCnt++; } // 次へ lzpGrp = lzpGrp->mzp1Next[lcpWork[j]]; // 個数 (lzpGrp->miCnt)++; } // 次回用 lcpWork += liLen + 1; } // クエリ数 - 取得 int liQCnt; fgets(lc1Buf, sizeof(lc1Buf), szpFpI); sscanf(lc1Buf, "%d", &liQCnt); // クエリ - 取得 for (i = 0; i < liQCnt; i++) { // 位置 - 取得 int liNo; fscanf(szpFpI, "%d", &liNo); liNo--; // 文字順序 - 取得 char lc1Ord[128]; fscanf(szpFpI, "%s", lc1Ord); fCutCrLf(lc1Ord); fgets(lc1Buf, sizeof(lc1Buf), szpFpI); // 順位 - 取得 int liONo = 1; Grp *lzpGrp = &sz1Grp[0]; for (j = 0; scp1Str[liNo][j] != 0; j++) { // 短い文字列 if (lzpGrp->mzp1Next[0] != NULL) { liONo += lzpGrp->mzp1Next[0]->miCnt; } // 前に来る文字列 for (k = 0; ; k++) { if (lc1Ord[k] == scp1Str[liNo][j]) { break; } if (lzpGrp->mzp1Next[lc1Ord[k]] != NULL) { liONo += lzpGrp->mzp1Next[lc1Ord[k]]->miCnt; } } // 次の文字へ lzpGrp = lzpGrp->mzp1Next[scp1Str[liNo][j]]; } // 出力 sprintf(lc1Buf, "%d\n", liONo); fOutLine(lc1Buf); } return 0; } // 1回実行 int fOne( ) { int liRet; char lc1Buf[1024]; // 入力 - セット #ifdef D_TEST sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo); szpFpI = fopen(lc1Buf, "r"); sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo); szpFpA = fopen(lc1Buf, "r"); siRes = 0; #else szpFpI = stdin; #endif // 実行メイン liRet = fMain(); // 残データ有無 #ifdef D_TEST lc1Buf[0] = '\0'; fgets(lc1Buf, sizeof(lc1Buf), szpFpA); if (strcmp(lc1Buf, "")) { siRes = -1; } #endif // テストファイルクローズ #ifdef D_TEST fclose(szpFpI); fclose(szpFpA); #endif // テスト結果 #ifdef D_TEST if (siRes == 0) { printf("OK %d\n", siTNo); } else { printf("NG %d\n", siTNo); } #endif return 0; } // プログラム開始 int main() { #ifdef D_TEST int i; for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) { siTNo = i; fOne(); } #else fOne(); #endif return 0; }
main.c:25:8: error: unknown type name 'Grp' 25 | static Grp sz1Grp[D_CHAR_MAX]; // グループ情報 | ^~~ main.c: In function 'fMain': main.c:101:17: error: unknown type name 'Grp'; use 'struct' keyword to refer to the type 101 | Grp *lzpGrp = &sz1Grp[0]; | ^~~ | struct main.c:105:35: error: request for member 'mzp1Next' in something not a structure or union 105 | if (lzpGrp->mzp1Next[lcpWork[j]] == NULL) { | ^~ main.c:106:39: error: request for member 'mzp1Next' in something not a structure or union 106 | lzpGrp->mzp1Next[lcpWork[j]] = &sz1Grp[siGCnt]; | ^~ main.c:111:40: error: request for member 'mzp1Next' in something not a structure or union 111 | lzpGrp = lzpGrp->mzp1Next[lcpWork[j]]; | ^~ main.c:114:32: error: request for member 'miCnt' in something not a structure or union 114 | (lzpGrp->miCnt)++; | ^~ main.c:142:17: error: unknown type name 'Grp'; use 'struct' keyword to refer to the type 142 | Grp *lzpGrp = &sz1Grp[0]; | ^~~ | struct main.c:146:35: error: request for member 'mzp1Next' in something not a structure or union 146 | if (lzpGrp->mzp1Next[0] != NULL) { | ^~ main.c:147:48: error: request for member 'mzp1Next' in something not a structure or union 147 | liONo += lzpGrp->mzp1Next[0]->miCnt; | ^~ main.c:155:43: error: request for member 'mzp1Next' in something not a structure or union 155 | if (lzpGrp->mzp1Next[lc1Ord[k]] != NULL) { | ^~ main.c:156:56: error: request for member 'mzp1Next' in something not a structure or union 156 | liONo += lzpGrp->mzp1Next[lc1Ord[k]]->miCnt; | ^~ main.c:161:40: error: request for member 'mzp1Next' in something not a structure or union 161 | lzpGrp = lzpGrp->mzp1Next[scp1Str[liNo][j]]; | ^~
s327064538
p03974
C++
#include <iostream> #include <iomanip> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <list> #include <stack> #include <queue> #include <bitset> #include <numeric> #include <cassert> #include <array> #include <memory> #ifdef DEBUG #include "./Lib/debug.hpp" #include "./Lib/Timer.hpp" #include "./Lib/sample.hpp" #else #define dump(...) #endif /* (=^o^=) */ #define int ll /* macro */ #define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i) #define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define REPC(x,c) for(const auto& x:(c)) #define REPI2(it,b,e) for(auto it = (b); it != (e); ++it) #define REPI(it,c) REPI2(it, (c).begin(), (c).end()) #define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend()) #define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);) #define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end()) #define ALL(x) (x).begin(),(x).end() #define cauto const auto& /* macro func */ template<class T> inline auto sort(T& t) { std::sort(ALL(t)); } template<class T> inline auto rsort(T& t) { std::sort((t).rbegin(), (t).rend()); } template<class T> inline auto unique(T& t) { (t).erase(unique((t).begin(), (t).end()), (t).end()); } template<class T, class S> inline auto chmax(T& t, const S& s) { if (s > t) { t = s; return true; } return false; } template<class T, class S> inline auto chmaxE(T& t, const S& s) { if (s >= t) { t = s; return true; } return false; } template<class T, class S> inline auto chmin(T& t, const S& s) { if (s < t) { t = s; return true; } return false; } inline auto BR() { std::cout << "\n"; } /* type define */ using ll = long long; using PAIR = std::pair<ll, ll>; using VS = std::vector<std::string>; using VL = std::vector<long long>; using VVL = std::vector<VL>; using VVVL = std::vector<VVL>; using VD = std::vector<double>; template<class T> using V = std::vector<T>; /* using std */ using std::cout; constexpr char endl = '\n'; using std::cin; using std::pair; using std::string; using std::stack; using std::queue; using std::vector; using std::list; using std::map; using std::unordered_map; using std::multimap; using std::unordered_multimap; using std::set; using std::unordered_set; using std::unordered_multiset; using std::multiset; using std::bitset; using std::priority_queue; using std::tuple; /* constant value */ constexpr ll MOD = 1000000007; //constexpr ll MOD = 998244353; /* Initial processing */ struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing; /* Remove the source of the bug */ inline signed pow(signed, signed) { assert(false); return -1; } /* define hash */ namespace std { template <> class hash<std::pair<ll, ll>> { public: size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; } /* input */ template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; } //============================================================================================= constexpr auto nullLambda = [](ll n) {}; template <class Val = bool, Val ignore = false> class TrieTree :public std::enable_shared_from_this<TrieTree<Val, ignore>> { Val m_val; ll end = 0; std::vector<std::shared_ptr<TrieTree>> m_next; std::vector<int> m_next_jump; // static constexpr auto nullLambda = [](ll n) {}; c++17 auto emplace(const std::vector<int>& vec, Val val, int it) { ++m_val; if (it == vec.size()) { ++end; return; } if (!m_next[vec[it]]) { m_next[vec[it]] = std::make_shared<TrieTree>(); } m_next[vec[it]]->emplace(vec, val, it + 1); } auto find(const std::vector<int>& vec, int it, const VL& order) const { if (m_val != ignore) { } if (it == vec.size()) { return 0LL; } ll cnt = 0; REP(i, 26) { if (vec[it] == order[i]) { if (m_next[order[i]]) { cnt += this->end; } break; } if (m_next[order[i]]) { cnt += m_next[order[i]]->m_val; } } //dump(cnt); if (!m_next[vec[it]]) { return cnt; } return cnt + m_next[vec[it]]->find(vec, it + m_next_jump[vec[it]], order); } template<class Lambda> auto find_old(const std::vector<int>& vec, int it, const Lambda& lambda)const { if (m_val != ignore) { lambda(m_val); } if (it >= vec.size()) { return m_val; } if (!m_next[vec[it]]) { return ignore; } return m_next[vec[it]]->find_old(vec, it + m_next_jump[vec[it]], lambda); } public: TrieTree() : TrieTree(ignore) {} TrieTree(Val val) : m_val(val), m_next(std::vector<std::shared_ptr<TrieTree>>(26)), m_next_jump(std::vector<int>(26, 1)) {} auto emplace(const std::vector<int>& vec, Val val) { return emplace(vec, val, 0); } template <class Lambda = decltype(nullLambda)> auto find(const std::vector<int>& vec, const VL& order) { return find(vec, 0, order); } //ptr, num auto compress(ll num) ->tuple<std::shared_ptr<TrieTree<Val, ignore>>, ll> { ll cnt = 0; ll it = -1; REP(i, 26) if (m_next[i]) { ++cnt; it = i; } if (cnt == 1) { auto ptr_n = m_next[it]->compress(num); auto ptr = std::get<0>(ptr_n); auto n = std::get<1>(ptr_n); m_next[it] = ptr; m_next_jump[it] = n; return tuple<std::shared_ptr<TrieTree<Val, ignore>>, ll>(ptr, n + 1); } REPC(ptr, m_next) if (ptr) { ptr->compress(0); } return tuple<std::shared_ptr<TrieTree<Val, ignore>>, ll>(shared_from_this(), num + 1); } template<class Lambda = decltype(nullLambda)> auto find_old(const std::vector<int>& vec, const Lambda& lambda = nullLambda) { return find_old(vec, 0, lambda); } }; signed main() { ll n; cin >> n; V<string> v(n); cin >> v; auto tree = std::make_shared<TrieTree<ll, 0>>(); auto to = [&](const string& s) { VL v; v.reserve(s.size()); REPC(c, s) { v.emplace_back(c - 'a'); } return v; }; REPC(s, v) { tree->emplace(to(s), 1); } ll q; cin >> q; REP(_, q) { ll k; string s; cin >> k >> s; auto ans = tree->find(to(v[k - 1]), to(s)); ++ans; cout << ans << endl; } }
a.cc: In member function 'std::tuple<std::shared_ptr<TrieTree<Val, ignore> >, long long int> TrieTree<Val, ignore>::compress(ll)': a.cc:197:74: error: there are no arguments to 'shared_from_this' that depend on a template parameter, so a declaration of 'shared_from_this' must be available [-fpermissive] 197 | return tuple<std::shared_ptr<TrieTree<Val, ignore>>, ll>(shared_from_this(), num + 1); | ^~~~~~~~~~~~~~~~ a.cc:197:74: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
s619224621
p03974
C++
#include <iostream> #include <iomanip> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <list> #include <stack> #include <queue> #include <bitset> #include <numeric> #include <cassert> #include <array> #include <memory> #ifdef DEBUG #include "./Lib/debug.hpp" #include "./Lib/Timer.hpp" #include "./Lib/sample.hpp" #else #define dump(...) #endif /* (=^o^=) */ #define int ll /* macro */ #define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i) #define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define REPC(x,c) for(const auto& x:(c)) #define REPI2(it,b,e) for(auto it = (b); it != (e); ++it) #define REPI(it,c) REPI2(it, (c).begin(), (c).end()) #define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend()) #define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);) #define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end()) #define ALL(x) (x).begin(),(x).end() #define cauto const auto& /* macro func */ template<class T> inline auto sort(T& t) { std::sort(ALL(t)); } template<class T> inline auto rsort(T& t) { std::sort((t).rbegin(), (t).rend()); } template<class T> inline auto unique(T& t) { (t).erase(unique((t).begin(), (t).end()), (t).end()); } template<class T, class S> inline auto chmax(T& t, const S& s) { if (s > t) { t = s; return true; } return false; } template<class T, class S> inline auto chmaxE(T& t, const S& s) { if (s >= t) { t = s; return true; } return false; } template<class T, class S> inline auto chmin(T& t, const S& s) { if (s < t) { t = s; return true; } return false; } inline auto BR() { std::cout << "\n"; } /* type define */ using ll = long long; using PAIR = std::pair<ll, ll>; using VS = std::vector<std::string>; using VL = std::vector<long long>; using VVL = std::vector<VL>; using VVVL = std::vector<VVL>; using VD = std::vector<double>; template<class T> using V = std::vector<T>; /* using std */ using std::cout; constexpr char endl = '\n'; using std::cin; using std::pair; using std::string; using std::stack; using std::queue; using std::vector; using std::list; using std::map; using std::unordered_map; using std::multimap; using std::unordered_multimap; using std::set; using std::unordered_set; using std::unordered_multiset; using std::multiset; using std::bitset; using std::priority_queue; using std::tuple; /* constant value */ constexpr ll MOD = 1000000007; //constexpr ll MOD = 998244353; /* Initial processing */ struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing; /* Remove the source of the bug */ inline signed pow(signed, signed) { assert(false); return -1; } /* define hash */ namespace std { template <> class hash<std::pair<ll, ll>> { public: size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; } /* input */ template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; } //============================================================================================= constexpr auto nullLambda = [](ll n) {}; template <class Val = bool, Val ignore = false> class TrieTree :public std::enable_shared_from_this<TrieTree<Val, ignore>> { Val m_val; ll end = 0; std::vector<std::shared_ptr<TrieTree>> m_next; std::vector<int> m_next_jump; // static constexpr auto nullLambda = [](ll n) {}; c++17 auto emplace(const std::vector<int>& vec, Val val, int it) { ++m_val; if (it == vec.size()) { ++end; return; } if (!m_next[vec[it]]) { m_next[vec[it]] = std::make_shared<TrieTree>(); } m_next[vec[it]]->emplace(vec, val, it + 1); } auto find(const std::vector<int>& vec, int it, const VL& order) const { if (m_val != ignore) { } if (it == vec.size()) { return 0LL; } ll cnt = 0; REP(i, 26) { if (vec[it] == order[i]) { if (m_next[order[i]]) { cnt += this->end; } break; } if (m_next[order[i]]) { cnt += m_next[order[i]]->m_val; } } //dump(cnt); if (!m_next[vec[it]]) { return cnt; } return cnt + m_next[vec[it]]->find(vec, it + m_next_jump[vec[it]], order); } template<class Lambda> auto find_old(const std::vector<int>& vec, int it, const Lambda& lambda)const { if (m_val != ignore) { lambda(m_val); } if (it >= vec.size()) { return m_val; } if (!m_next[vec[it]]) { return ignore; } return m_next[vec[it]]->find_old(vec, it + m_next_jump[vec[it]], lambda); } public: TrieTree() : TrieTree(ignore) {} TrieTree(Val val) : m_val(val), m_next(std::vector<std::shared_ptr<TrieTree>>(26)), m_next_jump(std::vector<int>(26, 1)) {} auto emplace(const std::vector<int>& vec, Val val) { return emplace(vec, val, 0); } template <class Lambda = decltype(nullLambda)> auto find(const std::vector<int>& vec, const VL& order) { return find(vec, 0, order); } //ptr, num auto compress(ll num) ->tuple<std::shared_ptr<TrieTree<Val, ignore>>, ll> { ll cnt = 0; ll it = -1; REP(i, 26) if (m_next[i]) { ++cnt; it = i; } if (cnt == 1) { auto ptr_n = m_next[it]->compress(num); auto ptr = std::get<0>(ptr_n); auto n = std::get<1>(ptr_n); m_next[it] = ptr; m_next_jump[it] = n; return tuple(ptr, n + 1); } REPC(ptr, m_next) if (ptr) { ptr->compress(0); } return tuple(shared_from_this(), num + 1); } template<class Lambda = decltype(nullLambda)> auto find_old(const std::vector<int>& vec, const Lambda& lambda = nullLambda) { return find_old(vec, 0, lambda); } }; signed main() { ll n; cin >> n; V<string> v(n); cin >> v; auto tree = std::make_shared<TrieTree<ll, 0>>(); auto to = [&](const string& s) { VL v; v.reserve(s.size()); REPC(c, s) { v.emplace_back(c - 'a'); } return v; }; REPC(s, v) { tree->emplace(to(s), 1); } ll q; cin >> q; REP(_, q) { ll k; string s; cin >> k >> s; auto ans = tree->find(to(v[k - 1]), to(s)); ++ans; cout << ans << endl; } }
a.cc: In member function 'std::tuple<std::shared_ptr<TrieTree<Val, ignore> >, long long int> TrieTree<Val, ignore>::compress(ll)': a.cc:197:30: error: there are no arguments to 'shared_from_this' that depend on a template parameter, so a declaration of 'shared_from_this' must be available [-fpermissive] 197 | return tuple(shared_from_this(), num + 1); | ^~~~~~~~~~~~~~~~ a.cc:197:30: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
s106863009
p03974
C++
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read (T &x) { bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-'); if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - 48; if (b) x = -x; } template <typename T> inline void wrip(T x) { if (x > 9) wrip(x / 10); putchar(x%10 + 48); } template <typename T> inline void write(T x) { if (x < 0) putchar('-'), x = -x; wrip(x);} void reads(string &s) { char c; while (!isalpha(c = getchar())); s = c; while (isalpha(c = getchar())) s += c; } typedef const int csint; const int N = 4e5 + 11; int n, Nnode, child[N][26], f[N], len[N], links[N]; int index[N]; string s[100011]; inline void add(string s, int pos) { int node = 0; for (int i = 0; i < s.size(); i++) { if (!child[node][s[i] - 'a']) { child[node][s[i] - 'a'] = ++Nnode; len[Nnode] = len[node] + 1; } node = child[node][s[i] - 'a']; } index[node] = pos; f[node]++; } inline int Solve(string str, int id) { int node = 0, res = 0; while(1) { if (links[node] != node) node = links[node]; res += (index[node] > 0); if (index[node] == id) break; int d = s[id][len[node]]; for (int j = 0; j <= 25; j++) { if (str[j] == d) break; if (child[node][str[j] - 'a']) res += f[child[node][str[j] - 'a']]; } node = child[node][d - 'a']; } return res; } int main() { #ifdef makacha freopen("m.inp", "r", stdin); freopen("m.out", "w", stdout); #endif // makacha read(n); for (int i = 1; i <= n; i++) { reads(s[i]); add(s[i], i); } for (int i = Nnode; i >= 0; i--) for (int j = 0; j <= 25; j++) if (child[i][j]) f[i] += f[child[i][j]]; for (int i = Nnode; i >= 0; i--) { links[i] = i; for (int j = 0; j <= 25; j++) if (child[i][j] && f[i] == f[child[i][j]]) links[i] = links[child[i][j]]; } int nquery; read(nquery); while (nquery--) { int k; string str; read(k); reads(str); write(Solve(str, k)); putchar('\n'); } }
a.cc:12:12: error: 'int index [400011]' redeclared as different kind of entity 12 | int index[N]; | ^ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121, from a.cc:1: /usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)' 50 | extern const char *index (const char *__s, int __c) | ^~~~~ a.cc: In function 'void add(std::string, int)': a.cc:23:10: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 23 | index[node] = pos; | ^ a.cc: In function 'int Solve(std::string, int)': a.cc:31:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 31 | res += (index[node] > 0); | ^ a.cc:32:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 32 | if (index[node] == id) | ^
s342232808
p03974
C++
#pragma once #include <iostream> #include <map> #include <memory> #include <vector> #include "misc/types.hpp" class patricia { public: struct node_t; using ptr_t = std::shared_ptr<node_t>; using const_ptr_t = std::shared_ptr<const node_t>; private: using pair = std::pair<std::shared_ptr<node_t>, usize>; public: struct node_t { node_t() = default; node_t(const std::string& prefix, const usize sub = 0, const usize count = 0) : prefix{prefix}, sub{sub}, count{count} {} std::string prefix{}; usize sub = 0, count = 0; std::map<char, ptr_t> child{}; friend std::ostream& operator<<(std::ostream& os, const node_t& node) { return os << "[" << node.prefix << "," << node.sub << "," << node.count << "]"; } static const pair next(const pair q, const std::string& s, const bool create = false) { const auto p = q.first; const auto index = q.second; const auto c = s[index]; if (p->child.find(c) == p->child.end()) { if (not create) { return pair{p, index}; } return p->child[c] = std::make_shared<node_t>(s.substr(index)), pair{p->child[c], s.size()}; } const auto prefix = p->child.at(c)->prefix; const usize n = s.size(), m = prefix.size(); usize lcp = 0; for (; index + lcp < n and lcp < m and s[index + lcp] == prefix[lcp]; lcp++) {} if (lcp == m) { return pair{p->child.at(c), index + lcp}; } if (not create) { return pair{p, index}; } const ptr_t nxt = p->child.at(c), mid = std::make_shared<node_t>(s.substr(index, lcp), nxt->sub); return mid->child[nxt->prefix[lcp]] = nxt, nxt->prefix = nxt->prefix.substr(lcp), p->child.at(c) = mid, pair{mid, index + lcp}; } }; patricia() : root{std::make_shared<node_t>()} {} void add(const std::string& s) { const usize n = s.size(); pair p{root, 0}; for (; p.second < n;) { p.first->sub++, p = node_t::next(p, s, true); } p.first->sub++, p.first->count++; } usize count(const std::string& s) const { const auto p = tail(s); return p.second == s.size() ? p.first->count : 0UL; } usize sub(const std::string& s) const { const auto p = tail(s); if (p.second == s.size()) { return p.first->sub; } const char c = s[p.second]; if (p.first->child.find(c) == p.first->child.end()) { return 0UL; } return p.first->child.at(c)->prefix.substr(0, s.size() - p.second) == s.substr(p.second) ? p.first->child.at(c)->sub : 0UL; } friend std::ostream& operator<<(std::ostream& os, const patricia& pat) { auto rec = [&](auto&& self, const auto p) { if (not p) { return; } os << "(" << *p; for (const auto& q : p->child) { self(self, q.second); } os << ")"; }; return rec(rec, pat.root), os; } const std::vector<const_ptr_t> path_to(const std::string& s) const { std::vector<const_ptr_t> ans; const usize n = s.size(); pair p{root, 0}; for (; p.second < n;) { ans.push_back(p.first); const auto prev = p.second; p = node_t::next(p, s, false); if (p.second == prev) { break; } } return ans.push_back(p.first), ans; } private: const pair tail(const std::string& s) const { const usize n = s.size(); pair p{root, 0}; for (; p.second < n;) { const auto prev = p.second; p = node_t::next(p, s, false); if (p.second == prev) { break; } } return p; } ptr_t root; };
a.cc:1:9: warning: #pragma once in main file 1 | #pragma once | ^~~~ a.cc:7:10: fatal error: misc/types.hpp: No such file or directory 7 | #include "misc/types.hpp" | ^~~~~~~~~~~~~~~~ compilation terminated.
s573594325
p03974
C++
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <math.h> #include <iomanip> #include <limits> #include <list> #include <queue> #include <tuple> #include <map> #include <stack> #include <set> using namespace std; #define MOD (long long int)(1e9+7) #define ll long long int #define rep(i,n) for(int i=0; i<(int)(n); i++) #define reps(i,n) for(int i=1; i<=(int)(n); i++) #define REP(i,n) for(int i=n-1; i>=0; i--) #define REPS(i,n) for(int i=n; i>0; i--) #define INF (int)(1123456789) #define LINF (long long int)(112345678901234567) #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) #define all(v) v.begin(), v.end() const int N = (int)3e5; ll mpow(ll a, ll b){ if(b==0) return 1; else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;} else return mpow(a,b-1) * a % MOD; } ll gcd(ll a, ll b){ if(b==0) return a; else return gcd(b, a%b); } vector<ll> kaijo_memo; ll kaijo(ll n){ if(kaijo_memo.size() > n) return kaijo_memo[n]; if(kaijo_memo.size() == 0) kaijo_memo.push_back(1); while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD); return kaijo_memo[n]; } ll nCr(ll n, ll r){ if(n < r || r < 0) return 0; ll ret = 1; ret *= kaijo(n); ret %= MOD; ret *= mpow(kaijo(r), MOD-2); ret %= MOD; ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD; return ret; } vector<vector<pair<string,int>>> G; vector<vector<int>> size; //ノードの圧縮を行う //再帰的に, 一個下の階層のsaikiのreturnを新たに子とする //子が1つしかないならその子のsaikiのreturnを返し, //複数ある場合は自分自身を返す pair<string,int> saiki(int now){ if(G[now].size() == 1){ pair<string,int> ret = saiki(G[now][i].second); ret.first.append(G[now][i].first); return ret; } rep(i, G[now].size()){ pair<string,int> ret = saiki(G[now][i].second); ret.first.append(G[now][i].first); G[now][i] = ret; } if(G[now].size()==1){ return pair<string,int>{G[now][0].first,G[now][0].second}; }else if(G[now].size()==0){ return pair<string,int>{"", now}; }else{ return pair<string,int>{"", now}; } } int count_size(int now){ int sum = 0; rep(i, G[now].size()){ int ret = count_size(G[now][i].second); sum += ret; size[now].push_back(ret); } if(G[now].size() == 0){ sum++; } return sum; } //各ノードにおいて, 自分より若いものの個数を加えていく //一致するものがあればその子ノードに対してsaikiし, そのreturnも加える //最後にその和をreturnする //0,0,s,p2i int calc(int now, int si, string s, vector<int> p2i){ /*rep(i,si){ cerr<<" "; } cerr<<"now:"<<now<<"s:"<<s<<"si:"<<si<<endl;*/ int sum = 0; rep(i, G[now].size()){ if(p2i[G[now][i].first.back() - '`'] > p2i[s[si] - '`']){ sum += size[now][i]; }else if(p2i[G[now][i].first.back() - '`'] == p2i[s[si] - '`']){ sum += calc(G[now][i].second, si + G[now][i].first.size(), s, p2i); } } /*rep(i,si){ cerr<<" "; } cerr<<sum<<endl;*/ return sum; } int main(void){ int n,q;cin>>n; vector<string> S; rep(i,n){ string s;cin>>s; S.push_back(s + "`"); } cin>>q; vector<pair<int,string>> query; rep(i,q){ int k; string p; cin>>k>>p; query.push_back({k,p}); } G.push_back(vector<pair<string,int>>()); //グラフを生成する 番号を割り振っていく //各ノードは辺(string,to)のリストを持つ //この段階では, stringの文字数は必ず1 //該当するstringがあればそこに遷移し, なければ子を新しく生成 rep(i,n){ string s = S[i]; int now = 0; rep(si, s.size()){ int next = -1; rep(gi, G[now].size()){ if(s[si] == G[now][gi].first[0]){ next = G[now][gi].second; break; } } if(next == -1){ next = G.size(); G[now].push_back({s.substr(si,1), next}); G.push_back(vector<pair<string,int>>()); now = next; }else{ now = next; } } } /*rep(i, G.size()){ rep(j, G[i].size()){ cerr<<i<<" "<<G[i][j].first<<" "<<G[i][j].second<<endl; } }*/ //ノードの圧縮を行う //再帰的に, 一個下の階層のsaikiのreturnを新たに子とする //子が1つしかないならその子のsaikiのreturnを返し, //複数ある場合は自分自身を返す saiki(0); return 0; /*cerr<<endl; rep(i, G.size()){ rep(j, G[i].size()){ cerr<<i<<" "<<G[i][j].first<<" "<<G[i][j].second<<endl; } }*/ //return 0; //葉の個数をカウント rep(i,G.size()){ size.push_back(vector<int>()); } count_size(0); //return 0; /*cerr<<endl; rep(i, G.size()){ rep(j, G[i].size()){ cerr<<i<<" "<<G[i][j].first<<" "<<G[i][j].second<<"size:"<<size[i][j]<<endl; } }*/ //queryを処理する //各ノードにおいて, 自分より若いものの個数を加えていく //一致するものがあればその子ノードに対してsaikiし, そのreturnも加える //最後にその和をreturnする rep(i,q){ int k = query[i].first; string p = query[i].second; string s = S[k-1]; vector<int> p2i; rep(i,27){ p2i.push_back(0); } rep(i,26){ p2i[p[i]-'`'] = i+1; } cout<<n - calc(0,0,s,p2i)<<endl; } return 0; }
a.cc: In function 'std::pair<std::__cxx11::basic_string<char>, int> saiki(int)': a.cc:65:41: error: 'i' was not declared in this scope 65 | pair<string,int> ret = saiki(G[now][i].second); | ^ a.cc: In function 'int count_size(int)': a.cc:88:5: error: reference to 'size' is ambiguous 88 | size[now].push_back(ret); | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:57:21: note: 'std::vector<std::vector<int> > size' 57 | vector<vector<int>> size; | ^~~~ a.cc: In function 'int calc(int, int, std::string, std::vector<int>)': a.cc:108:14: error: reference to 'size' is ambiguous 108 | sum += size[now][i]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:57:21: note: 'std::vector<std::vector<int> > size' 57 | vector<vector<int>> size; | ^~~~ a.cc: In function 'int main()': a.cc:181:5: error: reference to 'size' is ambiguous 181 | size.push_back(vector<int>()); | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:57:21: note: 'std::vector<std::vector<int> > size' 57 | vector<vector<int>> size; | ^~~~
s759944029
p03974
C++
めもだよー #include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <math.h> #include <iomanip> #include <limits> #include <list> #include <queue> #include <tuple> #include <map> #include <stack> #include <set> using namespace std; #define MOD (long long int)(1e9+7) #define ll long long int #define rep(i,n) for(int i=0; i<(int)(n); i++) #define reps(i,n) for(int i=1; i<=(int)(n); i++) #define REP(i,n) for(int i=n-1; i>=0; i--) #define REPS(i,n) for(int i=n; i>0; i--) #define INF (int)(1123456789) #define LINF (long long int)(112345678901234567) #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) #define all(v) v.begin(), v.end() const int N = (int)3e5; ll mpow(ll a, ll b){ if(b==0) return 1; else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;} else return mpow(a,b-1) * a % MOD; } ll gcd(ll a, ll b){ if(b==0) return a; else return gcd(b, a%b); } vector<ll> kaijo_memo; ll kaijo(ll n){ if(kaijo_memo.size() > n) return kaijo_memo[n]; if(kaijo_memo.size() == 0) kaijo_memo.push_back(1); while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD); return kaijo_memo[n]; } ll nCr(ll n, ll r){ if(n < r || r < 0) return 0; ll ret = 1; ret *= kaijo(n); ret %= MOD; ret *= mpow(kaijo(r), MOD-2); ret %= MOD; ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD; return ret; } vector<vector<pair<string,int>>> G; vector<vector<int>> size; //ノードの圧縮を行う //再帰的に, 一個下の階層のsaikiのreturnを新たに子とする //子が1つしかないならその子のsaikiのreturnを返し, //複数ある場合は自分自身を返す pair<string,int> saiki(int now){ rep(i, G[now].size()){ pair<string,int> ret = saiki(G[now][i].second); G[now][i].second = ret.second; G[now][i].first.append(ret.first); } if(G[now].size()==1){ return G[now][0]; }else if(G[now].size()==0){ return pair<string,int>{"", now}; }else{ return pair<string,int>{"", now}; } } int count_size(int now){ int sum = 0; rep(i, G[now].size()){ int ret = count_size(G[now][i].second); sum += ret; size[now].push_back(ret); } if(G[now].size() == 0){ sum++; } return sum; } //各ノードにおいて, 自分より若いものの個数を加えていく //一致するものがあればその子ノードに対してsaikiし, そのreturnも加える //最後にその和をreturnする //0,0,s,p2i int calc(int now, int si, string s, vector<int> p2i){ rep(i,si){ cerr<<" "; } cerr<<"now:"<<now<<endl; int sum = 0; rep(i, G[now].size()){ if(p2i[G[now][i].first[0] - '`'] > p2i[s[si] - '`']){ sum += size[now][i]; }else if(p2i[G[now][i].first[0] - '`'] == p2i[s[si] - '`']){ sum += calc(G[now][i].second, si + G[now][i].first.size(), s, p2i); } } rep(i,si){ cerr<<" "; } cerr<<sum<<endl; return sum; } int main(void){ int n,q;cin>>n; vector<string> S; rep(i,n){ string s;cin>>s; S.push_back(s + "`"); } cin>>q; vector<pair<int,string>> query; rep(i,q){ int k; string p; cin>>k>>p; query.push_back({k,p}); } G.push_back(vector<pair<string,int>>()); //グラフを生成する 番号を割り振っていく //各ノードは辺(string,to)のリストを持つ //この段階では, stringの文字数は必ず1 //該当するstringがあればそこに遷移し, なければ子を新しく生成 rep(i,n){ string s = S[i]; int now = 0; rep(si, s.size()){ int next = -1; rep(gi, G[now].size()){ if(s[si] == G[now][gi].first[0]){ next = G[now][gi].second; break; } } if(next == -1){ next = G.size(); G[now].push_back({s.substr(si,1), next}); G.push_back(vector<pair<string,int>>()); now = next; }else{ now = next; } } } rep(i, G.size()){ rep(j, G[i].size()){ cerr<<i<<" "<<G[i][j].first<<" "<<G[i][j].second<<endl; } } //ノードの圧縮を行う //再帰的に, 一個下の階層のsaikiのreturnを新たに子とする //子が1つしかないならその子のsaikiのreturnを返し, //複数ある場合は自分自身を返す saiki(0); cerr<<endl; rep(i, G.size()){ rep(j, G[i].size()){ cerr<<i<<" "<<G[i][j].first<<" "<<G[i][j].second<<endl; } } //葉の個数をカウント rep(i,G.size()){ size.push_back(vector<int>()); } count_size(0); /*cerr<<endl; rep(i, G.size()){ rep(j, G[i].size()){ cerr<<i<<" "<<G[i][j].first<<" "<<G[i][j].second<<"size:"<<size[i][j]<<endl; } }*/ //queryを処理する //各ノードにおいて, 自分より若いものの個数を加えていく //一致するものがあればその子ノードに対してsaikiし, そのreturnも加える //最後にその和をreturnする rep(i,q){ int k = query[i].first; string p = query[i].second; string s = S[k-1]; vector<int> p2i; rep(i,27){ p2i.push_back(0); } rep(i,26){ p2i[p[i]] = i+1; } cout<<calc(0,0,s,p2i)<<endl; } return 0; }
a.cc:1:1: error: '\U00003081\U00003082\U00003060\U00003088\U000030fc' does not name a type 1 | めもだよー | ^~~~~~~~~~ In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type 68 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~~~~~ /usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 40 | #include <cwchar> // For mbstate_t +++ |+#include <cstddef> 41 | In file included from /usr/include/c++/14/bits/exception_ptr.h:38, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared 140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared 142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:145:52: error: expected primary-expression before 'const' 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:147:54: error: expected primary-expression before 'const' 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive] 155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:156:70: error: expected primary-expression before 'const' 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive] 163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:164:72: error: expected primary-expression before 'const' 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared 171 | void operator delete(void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared 173 | void operator delete[](void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function 179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'st
s461617816
p03974
C++
#include <bits/stdc++.h> using namespace std; int n,c[100005][30][30],q,r[30],ans[100005]; string s[100005]; void dfs(vector<int> x,int l){ int o=0; vector<int>p[30]; for(int i=0;i<x.size();i++){ if(l<s[x[i]].size())p[s[x[i]][l]-'a'].PB(x[i]); else o++; } for(int i=0;i<x.size();i++){ if(s[x[i]].size()<=l)continue; ans[x[i]]+=o; for(int j=0;j<26;j++){ c[x[i]][s[x[i]][l]-'a'][j]+=int(p[j].size()); } } for(int i=0;i<26;i++)if(p[i].size())dfs(p[i],l+1); } int main(void){ scanf("%d",&n); for(int i=0;i<n;i++)cin>>s[i]; scanf("%d",&q); vector<int>x; for(int i=0;i<n;i++)x.PB(i); dfs(x,0); while(q--){ int k; scanf(" %d",&k); k--; int res=ans[k]; for(int i=0;i<26;i++){ char t; scanf(" %c",&t); r[t-'a']=i; } for(int i=0;i<26;i++){ for(int j=0;j<26;j++){ if(r[i]>r[j])res+=c[k][i][j]; } } printf("%d\n",res+1); } }
a.cc: In function 'void dfs(std::vector<int>, int)': a.cc:9:55: error: 'class std::vector<int>' has no member named 'PB' 9 | if(l<s[x[i]].size())p[s[x[i]][l]-'a'].PB(x[i]); | ^~ a.cc: In function 'int main()': a.cc:26:31: error: 'class std::vector<int>' has no member named 'PB' 26 | for(int i=0;i<n;i++)x.PB(i); | ^~
s329647887
p03974
C++
#include <algorithm> #include <iostream> #include <vector> #include <string> #include <unordered_map> using namespace std; unordered_map<char, int> currentOrder; struct comp { bool operator() (string a, string b) { int i = 0, j = 0; while (a[i] == b[j]) { ++i; ++j; if (i == a.length() || j == b.length()) { break; } } if (i == a.length() || j == b.length()) { return a.length() < b.length(); } else { return currentOrder[a[i]] < currentOrder[b[j]]; } } } comp; int find(vector<string> &str, string s) { int l = 0, r = str.size() - 1; while (l < r) { int mid = (l + r) / 2; if (comp(str[mid], s)) { l = mid + 1; } else { r = mid; } } return l; } int main(void) { int n; cin >> n; vector<string> str(n); for (int i = 0; i < n; ++i) { cin >> str[i]; } int q; cin >> q; vector<int> result(q, -1); unordered_map< string, vector< pair<string, int> > > table; for (int i = 0; i < q; ++i) { int idx; string order; cin >> idx >> order; table[order].push_back(make_pair(str[idx - 1], i)); } unordered_map< string, vector< pair<string, int> > >::iterator iter; for (iter = table.begin(); iter != table.end(); ++iter) { string order = iter->first; for (int i = 0; i < 26; ++i) { currentOrder[order[i]] = i; } currentOrder['\0'] = sort(str.begin(), str.end(), comp); /* for (int i = 0; i < str.size(); ++i) { cout << str[i] << endl; } cout << endl; */ for (int i = 0; i < iter->second.size(); ++i) { result[iter->second[i].second] = find(str, iter->second[i].first) + 1; } // break; } for (int i = 0; i < q; ++i) { cout << result[i] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:67:21: error: void value not ignored as it ought to be 67 | sort(str.begin(), str.end(), comp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s695110375
p03974
C++
#include <iostream> #include <vector> #include <string> #include <unordered_map> using namespace std; unordered_map<char, int> currentOrder; struct comp { bool operator() (string a, string b) { int i = 0, j = 0; while (a[i] == b[j]) { ++i; ++j; } return currentOrder[a[i]] < currentOrder[b[j]]; } } comp; int find(vector<string> &str, string s) { int l = 0, r = str.size() - 1; while (l < r) { int mid = (l + r) / 2; if (comp(str[mid], s)) { l = mid + 1; } else { r = mid; } } return l; } int main(void) { int n; cin >> n; vector<string> str(n); for (int i = 0; i < n; ++i) { cin >> str[i]; } int q; cin >> q; vector<int> result(q, -1); unordered_map< string, vector< pair<string, int> > > table; for (int i = 0; i < q; ++i) { int idx; string order; cin >> idx >> order; table[order].push_back(make_pair(str[idx - 1], i)); } unordered_map< string, vector< pair<string, int> > >::iterator iter; for (iter = table.begin(); iter != table.end(); ++iter) { string order = iter->first; for (int i = 0; i < 26; ++i) { currentOrder[order[i]] = i; } sort(str.begin(), str.end(), comp); /* for (int i = 0; i < str.size(); ++i) { cout << str[i] << endl; } cout << endl; */ for (int i = 0; i < iter->second.size(); ++i) { result[iter->second[i].second] = find(str, iter->second[i].first) + 1; } // break; } for (int i = 0; i < q; ++i) { cout << result[i] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:58:17: error: 'sort' was not declared in this scope; did you mean 'short'? 58 | sort(str.begin(), str.end(), comp); | ^~~~ | short
s879974569
p03974
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int,string> P; typedef pair<int,int> PP; typedef pair<string,int> PPP; int N,Q,K,X,Y,Max,index,ans; const int A=400010,B=100010; const int INF=1000000009; char C[A]; int parent[A],Parent[A],node[A],Node[A],O[30]; int G[B]; PPP H[B]; int J[B]; int JJ[B]; vector<int> ch[A],L[A]; string S[B],T[B],U[B],V[B]; void dfs(int s,int e,int j,int p){ int x=S[s][j]-'a'; int k=s; for(int i=s; i<=e; i++){ if(x!=S[i][j]-'a'){ dfs(k,i-1,j,p); k=i; x=S[i][j]-'a'; } } //cout<<x<<" "<<j<<" "<<index++<<" "<<p<<endl; node[index]=x; if(j==0) parent[index]=A-1; else parent[index]=p; index++; if(x<0) return; if(j<Max) dfs(k,e,j+1,index-1); return; } int Pr(int k){ int p=parent[k]; if(p==A-1) return A-1; if(ch[parent[p]].size()==1){ return Pr(p); }else{ return p; } } void order(int k){ if(L[k].size()==0){ return; } vector<PP> o; for(int i=0; i<L[k].size(); i++){ if(node[L[k][i]]==-INF) o.push_back(PP(-INF,L[k][i])); else{ int w=O[node[L[k][i]]]; o.push_back(PP(w,L[k][i])); } } sort(o.begin(),o.end()); for(int j=0; j<o.size(); j++){ if(j==0) Y--; Node[o[j].second]=Y; Y++; order(o[j].second); } return; } void make(int k){ if(L[k].size()==0){ //cout<<k<<endl; J[X]=node[k]; JJ[X]=k; X++; return; } for(int i=0; i<L[k].size(); i++){ make(L[k][i]); } } //どのノードをみるべきか void Find(int k,int j){ if(L[k].size()==0){ ans=Node[k]; return; } for(int i=0; i<L[k].size(); i++){ if(V[G[K-1]][j]-'a'==node[L[k][i]]){ Find(L[k][i],j+1); } } } int main(){ cin>>N; for(int i = 0; i < N; i++){ scanf("%s", C); S[i] = string(C); if(S[i].size()>Max) Max=S[i].size(); } for(int i = 0; i < N; i++) U[i]=S[i]; sort(S,S+N); dfs(0,N-1,0,A-1); for(int i = 0; i < index; i++){ if(parent[i]>=0) ch[parent[i]].push_back(i); } for(int i = 0; i < index; i++){ int p=parent[i]; if(ch[p].size()==1&&p>=0) node[i]=-INF; } for(int i = 0; i < index; i++){ if(node[i]>-INF){ Parent[i]=Pr(i); }else{ Parent[i]=-INF; } } for(int i = 0; i < index; i++){ if(Parent[i]>=0) L[Parent[i]].push_back(i); } //cout<<L[A-1][1]<<endl; make(A-1); for(int i=0; i<N; i++){ if(J[i]>=0){ char c='a'+J[i]; V[i]=c; }else{ V[i]=""; } //cout<<V[i]<<endl; int k=JJ[i]; while(1){ if(Parent[k]==A-1) break; char c='a'+node[Parent[k]]; V[i]=c+V[i]; k=Parent[k]; } } sort(V,V+N); /*V[0]="aa"; //aa V[1]="aba"; //abbaa V[2]="abb"; //abbba V[3]="aaab"; //aaab V[4]="aaaa";*/ //aaaaaba for(int i=0; i<N; i++){ H[i].first=U[i]; H[i].second=i; } sort(H,H+N); for(int i=0; i<N; i++){ G[H[i].second]=i; } /*for(int i=0; i<N; i++){ cout<<V[i]<<endl; }*/ cin>>Q; for(int i=0; i<Q; i++){ scanf("%d %s",&K,C); T[i] = string(C); for(int j=0; j<26; j++){ T[i][j]-'a'; O[T[i][j]-'a']=j; } X=0; Y=1; index=0; order(A-1); Find(A-1,0); printf("%d\n",ans+1); } //cout<<Node[22]<<endl; return 0; }
a.cc:8:19: error: 'int index' redeclared as different kind of entity 8 | int N,Q,K,X,Y,Max,index,ans; | ^~~~~ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121, from a.cc:1: /usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)' 50 | extern const char *index (const char *__s, int __c) | ^~~~~ a.cc: In function 'void dfs(int, int, int, int)': a.cc:29:14: error: invalid types 'int [400010][<unresolved overloaded function type>]' for array subscript 29 | node[index]=x; | ^ a.cc:30:25: error: invalid types 'int [400010][<unresolved overloaded function type>]' for array subscript 30 | if(j==0) parent[index]=A-1; | ^ a.cc:31:21: error: invalid types 'int [400010][<unresolved overloaded function type>]' for array subscript 31 | else parent[index]=p; | ^ a.cc:32:15: error: no post-increment operator for type 32 | index++; | ^~ a.cc:34:36: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator-' 34 | if(j<Max) dfs(k,e,j+1,index-1); | ~~~~~^~ a.cc: In function 'int main()': a.cc:112:18: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<' 112 | for(int i = 0; i < index; i++){ | ~~^~~~~~~ a.cc:116:18: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<' 116 | for(int i = 0; i < index; i++){ | ~~^~~~~~~ a.cc:121:18: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<' 121 | for(int i = 0; i < index; i++){ | ~~^~~~~~~ a.cc:129:18: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<' 129 | for(int i = 0; i < index; i++){ | ~~^~~~~~~ a.cc:183:11: error: overloaded function with no contextual type information 183 | index=0; | ^
s707423725
p03974
C++
#include <bits/stdc++.h> using namespace std; #define fin "qualB_E.inp" #define fou "" #define ff(i, a, b) for(int i = a; i <= b; i ++) #define fd(i, a, b) for(int i = a; i >= b; i --) #define x first #define y second //#define endl '\n' typedef long long data; typedef pair<int,int> ii; typedef vector<int> vi; typedef vector<ii> vii; const int N = 1e5 + 10; const int M = 5e5; int n, q, k; string s[N], p; int num, next[M][26], endstr[M], f[M]; void read() { cin >> n; ff(i, 1, n) cin >> s[i]; cin >> q; } void build() { num = 1; int u, v; ff(i, 1, n) { u = 1; ff(j, 1, s[i].size()) { if (!next[u][s[i][j - 1] - 'a']) next[u][s[i][j - 1] - 'a'] = ++ num; u = next[u][s[i][j - 1] - 'a']; } endstr[u] = i; } } void visit(int u) { int v; if (endstr[u]) f[u] = 1; ff(c, 0, 25) { v = next[u][c]; if (v) visit(v); f[u] += f[v]; } } void solve() { build(); visit(1); int u, v, c, ans; while (q --) { cin >> k >> p; u = 1; ans = 0; ff(i, 1, s[k].size()) { ff(j, 1, p.size()) { c = p[j - 1] - 'a'; v = next[u][c]; if (c != s[k][i - 1] - 'a') ans += f[v]; else { //cout << (char) (c + 'a') << " " << v << endl; u = v; if (endstr[u]) ++ ans; break; } } } cout << ans << endl; } } int main() { ios_base::sync_with_stdio(0); //freopen(fin,"r",stdin), freopen(fou,"w",stdout); read(); solve(); return 0; }
a.cc: In function 'void build()': a.cc:36:18: error: reference to 'next' is ambiguous 36 | if (!next[u][s[i][j - 1] - 'a']) | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:19:10: note: 'int next [500000][26]' 19 | int num, next[M][26], endstr[M], f[M]; | ^~~~ a.cc:37:17: error: reference to 'next' is ambiguous 37 | next[u][s[i][j - 1] - 'a'] = ++ num; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:19:10: note: 'int next [500000][26]' 19 | int num, next[M][26], endstr[M], f[M]; | ^~~~ a.cc:38:17: error: reference to 'next' is ambiguous 38 | u = next[u][s[i][j - 1] - 'a']; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:19:10: note: 'int next [500000][26]' 19 | int num, next[M][26], endstr[M], f[M]; | ^~~~ a.cc: In function 'void visit(int)': a.cc:49:13: error: reference to 'next' is ambiguous 49 | v = next[u][c]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:19:10: note: 'int next [500000][26]' 19 | int num, next[M][26], endstr[M], f[M]; | ^~~~ a.cc: In function 'void solve()': a.cc:69:21: error: reference to 'next' is ambiguous 69 | v = next[u][c]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:19:10: note: 'int next [500000][26]' 19 | int num, next[M][26], endstr[M], f[M]; | ^~~~
s156345991
p03974
C++
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; struct S_STRU{ int id; string s; }; string g_Rule; int compChar(char ch1,char ch2) { int ch1Pos=-1,ch2Pos=-1; for (int i=0;i<26;i++){ if (g_Rule[i] == ch1){ ch1Pos = i; } if (g_Rule[i] == ch2){ ch2Pos = i; } if (ch1Pos != -1 && ch2Pos != -1){ break; } } if (ch1Pos>ch2Pos){ return 1; } if (ch1Pos==ch2Pos){ return 0; } if (ch1Pos<ch2Pos){ return -1; } } bool less(const S_STRU& s1,const S_STRU& s2) { int sLen1 = s1.s.length(); int sLen2 = s2.s.length(); int sLen = min(sLen1,sLen2); int pos=0; for (int i=0;i<sLen;i++){ pos=compChar(s1.s[i],s2.s[i]); if (pos<0){ return true;//s1<s2 }else if (pos>0){ return false;//s1>s2 } } if (sLen1<sLen2){ return true; }else{ return false; } } int main(int argc, char* argv[]) { int N,Q; cin>>N; int i; vector<S_STRU> S(N); vector<S_STRU> S_Sort(N); string _s; for (i=0;i<N;i++){ S[i].id = i+1; cin>>S[i].s; S_Sort[i].id=S[i].id; S_Sort[i].s=S[i].s; } cin>>Q; vector<int> k(Q); vector<string> p(Q); for (i=0;i<Q;i++){ cin>>k[i]; cin>>p[i]; } for (i=0;i<Q;i++){ g_Rule = p[i]; sort(S_Sort.begin(),S_Sort.end(),less); for (int j=0;j<S_Sort.size();j++){ if (S[k[i]-1].id==S_Sort[j].id){ cout<<j+1<<endl; break; } } } return 0; }
a.cc: In function 'int main(int, char**)': a.cc:80:50: error: reference to 'less' is ambiguous 80 | sort(S_Sort.begin(),S_Sort.end(),less); | ^~~~ In file included from /usr/include/c++/14/string:49, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_function.h:356:12: note: candidates are: 'template<class _Tp> struct std::less' 356 | struct less; | ^~~~ a.cc:36:6: note: 'bool less(const S_STRU&, const S_STRU&)' 36 | bool less(const S_STRU& s1,const S_STRU& s2) | ^~~~ a.cc: In function 'int compChar(char, char)': a.cc:34:1: warning: control reaches end of non-void function [-Wreturn-type] 34 | } | ^
s236852301
p03974
C++
#include <iostream> #include <cassert> #include <vector> // #include <algorithm> using namespace std; class TrieNode { public: void add(const char *p) { assert(*p); m_count++; if (m_count == 1) { m_pVal = p; m_isEnd = 1; return; } assert(*p == *m_pVal); if (m_next.empty()) { m_next.resize(26); const char *p1 = m_pVal + 1; if (*p1) m_next[*p1 - 'a'].add(p1); m_isEnd = (int)(!(*p1)); } if (*(++p)) m_next[*p - 'a'].add(p); else m_isEnd = 1; } // private: int m_count = 0; const char *m_pVal = 0; int m_isEnd = 0; vector<TrieNode> m_next; }; class TrieRoot { public: TrieRoot() : m_next(26) {} inline void add(const string &s) { if (!s.empty()) m_next[s[0] - 'a'].add(s.c_str()); } int query(const string &s, const string &order) { if (s.empty()) return 1; int c = 0; const char *p = s.c_str(); for (char ch : order) { if (ch == *p) break; c += m_next[ch - 'a'].m_count; } auto *pCurr = &m_next[*p - 'a']; while (*++p) { if (pCurr->m_count == 1) return c + 1; if (p - s.c_str() > 100000) return -1; // cout << *p << pCurr->m_isEnd << endl; while(*(p+1) && pCurr->m_count == pCurr->m_next[*p - 'a'].m_count) pCurr = &pCurr->m_next[*p++ - 'a']; c += pCurr->m_isEnd; for (char ch : order) { if (ch == *p) break; c += pCurr->m_next[ch - 'a'].m_count; } pCurr = &pCurr->m_next[*p - 'a']; } return c + 1; } private: vector<TrieNode> m_next; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q, k; string s, o; TrieRoot root; vector<string> vs; cin >> n; for (int i = 0; i < n; i++) { cin >> s; vs.push_back(s); root.add(s); } // vector<string> vs1(vs); // sort(vs1.begin(), vs1.end()); // for (auto &str : vs1) // root.add(str); cin >> q; for (int i = 0; i < q; i++) { cin >> k >> o; // cout << k << ' ' << vs[k-1] << ' ' << o << endl; if (N == 1) cout << 1 << endl; else cout << root.query(vs[k-1], o) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:103:21: error: 'N' was not declared in this scope 103 | if (N == 1) | ^
s551516195
p03974
C++
#include <iostream> #include <cassert> #include <vector> using namespace std; class TrieNode { public: void add(const char *p) { // assert(*p); m_count++; if (m_count == 1) { m_pVal = p; m_isEnd = 1; return; } if (m_next.empty()) { m_next.resize(26); const char *p1 = m_pVal + 1; if (*p1) m_next[*p1 - 'a'].add(p1); m_isEnd = (int)(!(*p1)); } if (*(++p)) m_next[*p - 'a'].add(p); else m_isEnd = 1; } // private: int m_count = 0; const char *m_pVal = 0; int m_isEnd = 0; vector<TrieNode> m_next; }; class TrieRoot { public: TrieRoot() : m_next(26) {} inline void add(const string &s) { if (!s.empty()) m_next[s[0] - 'a'].add(s.c_str()); } int getRank(const string &s, const string &order) { if (s.empty()) return 1; int c = 0; const char *p = s.c_str(); for (char ch : order) { if (ch == *p) break; c += m_next[ch - 'a'].m_count; } auto *pNext = &m_next[*p++ - 'a']; while (*p) { // cout << *p << pNext->m_isEnd; if (pNext->m_count == 1) return c + 1; while(*(p+1) && pNext->m_count == pNext->m_next[*p - 'a'].m_count) pNext = &pNext->m_next[*p++ - 'a']; c += pNext->m_isEnd; for (char ch : order) { if (ch == *p) break; c += pNext->m_next[ch - 'a'].m_count; } pNext = &pNext->m_next[*p++ - 'a']; } return c + 1; } private: vector<TrieNode> m_next; }; int main() { int n, q, k; TrieRoot root; vector<string> vs; string s; cin >> n; for (int i = 0; i < n; i++) { cin >> s; vs.push_back(s); // root.add(s); } vector<string> vs1(vs); sort(vs1.begin(), vs1.end()); for (auto &str : vs1) root.add(str); cin >> q; for (int i = 0; i < q; i++) { cin >> k >> s; // cout << k << ' ' << vs[k-1] << ' ' << s << endl; cout << root.getRank(vs[k-1], s) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:90:9: error: 'sort' was not declared in this scope; did you mean 'short'? 90 | sort(vs1.begin(), vs1.end()); | ^~~~ | short
s478022602
p03974
C++
#include<iostream> using namespace std; const int NQmax = 100000; int N,Q; string S[NQmax]; int prefix[NQmax]; int former[26][26][NQmax]; struct trie { int k; // index of this node int n; // number of children struct trie *c[26]; }; void init(struct trie *t){ t->k = -1; t->n = 0; for(int i=0; i<26; i++) t->c[i] = NULL; } struct trie *add(struct trie *t, string s){ t->n++; if(s.empty()) return t; int c = s[0]-'a'; if(t->c[c] == NULL){ t->c[c] = new struct trie; init(t->c[c]); } return add(t->c[c], s.substr(1, s.size()-1)); } int main(){ cin >> N; for(int i=0; i<N; i++){ cin >> S[i]; } struct trie *root = new struct trie; init(root); for(int i=0; i<N; i++){ add(root, S[i])->k = i; } for(int i=0; i<N; i++){ struct trie *t=root; for(int j=0; j<S[i].size(); j++){ int c = S[i][j]-'a'; struct trie* s = t->c[c]; if(t->k >= 0) prefix[i]++; for(int k=0; k<26; k++){ if(k==S[i][j]-'a'|| t->c[k]==NULL) continue; former[k][c][i] += t->c[k]->n; } t=s; } } cin >> Q; for(int i=0; i<Q; i++){ cin >> K[i]; cin >> P[i]; int res = prefix[K[i]-1]+1; for(int j=0; j<26; j++){ for(int k=j; k<26; k++){ res += former[P[i][j]-'a'][P[i][k]-'a'][K[i]-1]; } } cout << res << endl; } return 0; }
a.cc: In function 'int main()': a.cc:60:12: error: 'K' was not declared in this scope 60 | cin >> K[i]; | ^ a.cc:61:12: error: 'P' was not declared in this scope 61 | cin >> P[i]; | ^
s601145317
p03974
C++
#include <bits/stdc++.h> using namespace std; struct st{ st *linkk[27]; st *up; int cnt; int belong; int att; int val; int en; st(){ for (int i = 0; i < 27; i++){ linkk[i] = NULL; } cnt = 0; en = 0; } }; int n; int q; #define MAX 400002 char buf[MAX]; vector<string> v; st linkk2[MAX * 27]; int ord = 0; st *neww(){ ord++; return &linkk2[ord - 1]; } st *root; vector<st*> lis; void ins(string a){ st *b = root; for (int i = 0; i < a.size(); i++){ if (b->linkk[a[i] - 'a'] == NULL){ b->linkk[a[i] - 'a'] = neww(); b->linkk[a[i] - 'a']->up = b; } b = b->linkk[a[i] - 'a']; } b->en++; lis.push_back(b); } inline void dfs(st *b){ bool f = false; b->cnt = b->en; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ f = true; b->linkk[i]->val = i; dfs(b->linkk[i]); b->cnt += b->linkk[i]->cnt; } } } map < st*, vector<pair<string, int> > > mp; int store[27][27]; int outt[MAX]; int F = 0; inline void dfs2(st *b){ F += b->en; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ for (int j = 0; j < 26; j++){ if (i != j){ if (b->linkk[j] != NULL){ store[i][j] += b->linkk[j]->cnt; } } } dfs2(b->linkk[i]); for (int j = 0; j < 26; j++){ if (i != j){ if (b->linkk[j] != NULL){ store[i][j] -= b->linkk[j]->cnt; } } } } } F-=b->en; if (mp.count(b)){ vector<pair<string, int> > &V = mp[b]; for (int i = 0; i < V.size(); i++){ int ans = 0; for (int j = 0; j < 26; j++){ for (int k = 0; k < j; k++){ ans += store[V[i].first[j]-'a'][V[i].first[k]-'a']; } } outt[V[i].second] = ans+F; } } } int main(){ root = neww(); root->up = NULL; cin >> n; for (int i = 0; i < n; i++){ scanf("%s", buf); v.push_back(buf); ins(v.back()); } dfs(root); int q; scanf("%d", &q); for (int i = 0; i < q; i++){ int id; scanf("%d", &id); id--; scanf("%s", buf); mp[lis[id]].push_back(make_pair(buf,i) ); } dfs2(root); for (int i = 0; i < q; i++){ printf("%d\n", outt[i] + 1); } return 0; }
/tmp/ccWwktBX.o: in function `neww()': a.cc:(.text+0x6): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/ccWwktBX.o a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/ccWwktBX.o a.cc:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/ccWwktBX.o /tmp/ccWwktBX.o: in function `ins(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)': a.cc:(.text+0x4b): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccWwktBX.o a.cc:(.text+0x161): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/ccWwktBX.o /tmp/ccWwktBX.o: in function `main': a.cc:(.text+0x18b): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccWwktBX.o a.cc:(.text+0x192): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccWwktBX.o a.cc:(.text+0x298): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccWwktBX.o a.cc:(.text+0x32a): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/ccWwktBX.o a.cc:(.text+0x33c): relocation truncated to fit: R_X86_64_PC32 against symbol `mp[abi:cxx11]' defined in .bss section in /tmp/ccWwktBX.o a.cc:(.text+0x3c0): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s543904566
p03974
C++
#include <bits/stdc++.h> using namespace std; struct st{ st *linkk[27]; st *up; int cnt; int belong; int att; int val; int en; st(){ for (int i = 0; i < 27; i++){ linkk[i] = NULL; } cnt = 0; en = 0; } }; int n; int q; #define MAX 400002 char buf[MAX]; vector<string> v; st linkk2[MAX * 30]; int ord = 0; st *neww(){ ord++; return &linkk2[ord - 1]; } st *root; vector<st*> lis; void ins(string a){ st *b = root; for (int i = 0; i < a.size(); i++){ if (b->linkk[a[i] - 'a'] == NULL){ b->linkk[a[i] - 'a'] = neww(); b->linkk[a[i] - 'a']->up = b; } b = b->linkk[a[i] - 'a']; } b->en++; lis.push_back(b); } inline void dfs(st *b){ bool f = false; b->cnt = b->en; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ f = true; b->linkk[i]->val = i; dfs(b->linkk[i]); b->cnt += b->linkk[i]->cnt; } } } map < st*, vector<pair<string, int> > > mp; int store[27][27]; int outt[MAX]; int F = 0; inline void dfs2(st *b){ F += b->en; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ for (int j = 0; j < 26; j++){ if (i != j){ if (b->linkk[j] != NULL){ store[i][j] += b->linkk[j]->cnt; } } } dfs2(b->linkk[i]); for (int j = 0; j < 26; j++){ if (i != j){ if (b->linkk[j] != NULL){ store[i][j] -= b->linkk[j]->cnt; } } } } } F-=b->en; if (mp.count(b)){ vector<pair<string, int> > &V = mp[b]; for (int i = 0; i < V.size(); i++){ int ans = 0; for (int j = 0; j < 26; j++){ for (int k = 0; k < j; k++){ ans += store[V[i].first[j]-'a'][V[i].first[k]-'a']; } } outt[V[i].second] = ans+F; } } } int main(){ root = neww(); root->up = NULL; cin >> n; for (int i = 0; i < n; i++){ scanf("%s", buf); v.push_back(buf); ins(v.back()); } dfs(root); int q; scanf("%d", &q); for (int i = 0; i < q; i++){ int id; scanf("%d", &id); id--; scanf("%s", buf); mp[lis[id]].push_back(make_pair(buf,i) ); } dfs2(root); for (int i = 0; i < q; i++){ printf("%d\n", outt[i] + 1); } return 0; }
/tmp/cc99Z3Rs.o: in function `neww()': a.cc:(.text+0x6): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/cc99Z3Rs.o a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/cc99Z3Rs.o a.cc:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/cc99Z3Rs.o /tmp/cc99Z3Rs.o: in function `ins(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)': a.cc:(.text+0x4b): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cc99Z3Rs.o a.cc:(.text+0x161): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/cc99Z3Rs.o /tmp/cc99Z3Rs.o: in function `main': a.cc:(.text+0x18b): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cc99Z3Rs.o a.cc:(.text+0x192): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cc99Z3Rs.o a.cc:(.text+0x298): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cc99Z3Rs.o a.cc:(.text+0x32a): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/cc99Z3Rs.o a.cc:(.text+0x33c): relocation truncated to fit: R_X86_64_PC32 against symbol `mp[abi:cxx11]' defined in .bss section in /tmp/cc99Z3Rs.o a.cc:(.text+0x3c0): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s635602448
p03974
C++
#include <bits/stdc++.h> using namespace std; struct st{ st *linkk[27]; st *up; int cnt; int belong; int att; int val; int en; st(){ for (int i = 0; i < 27; i++){ linkk[i] = NULL; } cnt = 0; en = 0; } }; int n; int q; #define MAX 400002 char buf[MAX]; vector<string> v; st linkk2[MAX * 30]; int ord = 0; st *neww(){ ord++; return &linkk2[ord - 1]; } st *root; vector<st*> lis; void ins(string &a){ st *b = root; for (int i = 0; i < a.size(); i++){ if (b->linkk[a[i] - 'a'] == NULL){ b->linkk[a[i] - 'a'] = neww(); b->linkk[a[i] - 'a']->up = b; } b = b->linkk[a[i] - 'a']; } b->en++; lis.push_back(b); } inline void dfs(st *b){ bool f = false; b->cnt = b->en; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ f = true; b->linkk[i]->val = i; dfs(b->linkk[i]); b->cnt += b->linkk[i]->cnt; } } } map < st*, vector<pair<string, int> > > mp; int store[27][27]; int outt[MAX]; int F = 0; inline void dfs2(st *b){ F += b->en; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ for (int j = 0; j < 26; j++){ if (i != j){ if (b->linkk[j] != NULL){ store[i][j] += b->linkk[j]->cnt; } } } dfs2(b->linkk[i]); for (int j = 0; j < 26; j++){ if (i != j){ if (b->linkk[j] != NULL){ store[i][j] -= b->linkk[j]->cnt; } } } } } F-=b->en; if (mp.count(b)){ vector<pair<string, int> > &V = mp[b]; for (int i = 0; i < V.size(); i++){ int ans = 0; for (int j = 0; j < 26; j++){ for (int k = 0; k < j; k++){ ans += store[V[i].first[j]-'a'][V[i].first[k]-'a']; } } outt[V[i].second] = ans+F; } } } int main(){ root = neww(); root->up = NULL; cin >> n; for (int i = 0; i < n; i++){ scanf("%s", buf); v.push_back(buf); ins(v.back()); } dfs(root); int q; scanf("%d", &q); for (int i = 0; i < q; i++){ int id; scanf("%d", &id); id--; scanf("%s", buf); mp[lis[id]].push_back(make_pair(buf,i) ); } dfs2(root); for (int i = 0; i < q; i++){ printf("%d\n", outt[i] + 1); } return 0; }
/tmp/cc00UJ73.o: in function `neww()': a.cc:(.text+0x6): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/cc00UJ73.o a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/cc00UJ73.o a.cc:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/cc00UJ73.o /tmp/cc00UJ73.o: in function `ins(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': a.cc:(.text+0x4b): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cc00UJ73.o a.cc:(.text+0x161): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/cc00UJ73.o /tmp/cc00UJ73.o: in function `main': a.cc:(.text+0x18b): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cc00UJ73.o a.cc:(.text+0x192): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cc00UJ73.o a.cc:(.text+0x26d): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cc00UJ73.o a.cc:(.text+0x2ff): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/cc00UJ73.o a.cc:(.text+0x311): relocation truncated to fit: R_X86_64_PC32 against symbol `mp[abi:cxx11]' defined in .bss section in /tmp/cc00UJ73.o a.cc:(.text+0x395): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s804932367
p03974
C++
#include <bits/stdc++.h> using namespace std; struct st{ st *linkk[27]; st *up; int cnt; int belong; int att; int val; int en; st(){ for (int i = 0; i < 27; i++){ linkk[i] = NULL; } cnt = 0; en = 0; } }; int n; int q; #define MAX 400002 char buf[MAX]; vector<string> v; st linkk2[MAX * 30]; int ord = 0; st *neww(){ ord++; return &linkk2[ord - 1]; } st *root; vector<st*> lis; void ins(string &a){ st *b = root; for (int i = 0; i < a.size(); i++){ if (b->linkk[a[i] - 'a'] == NULL){ b->linkk[a[i] - 'a'] = neww(); b->linkk[a[i] - 'a']->up = b; } b = b->linkk[a[i] - 'a']; } b->en++; lis.push_back(b); } inline void dfs(st *b){ bool f = false; b->cnt = b->en; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ f = true; b->linkk[i]->val = i; dfs(b->linkk[i]); b->cnt += b->linkk[i]->cnt; } } } map < st*, vector<pair<string, int> > > mp; int store[27][27]; int outt[MAX]; int F = 0; inline void dfs2(st *b){ int t[26]; F += b->en; memset(t, 0, sizeof(t)); for (int i = 0; i < 26; i++){ if (b->linkk[i] == NULL){ } else{ t[i] += b->linkk[i]->cnt; } } for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ for (int j = 0; j < 26; j++){ if (i != j){ store[i][j] += t[j]; } } dfs2(b->linkk[i]); for (int j = 0; j < 26; j++){ if (i != j){ store[i][j] -= t[j]; } } } } F-=b->en; if (mp.count(b)){ vector<pair<string, int> > &V = mp[b]; for (int i = 0; i < V.size(); i++){ int ans = 0; for (int j = 0; j < 26; j++){ for (int k = 0; k < j; k++){ ans += store[V[i].first[j]-'a'][V[i].first[k]-'a']; } } outt[V[i].second] = ans+F; } } } int main(){ root = neww(); root->up = NULL; cin >> n; for (int i = 0; i < n; i++){ scanf("%s", buf); v.push_back(buf); ins(v.back()); } dfs(root); int q; scanf("%d", &q); for (int i = 0; i < q; i++){ int id; scanf("%d", &id); id--; scanf("%s", buf); mp[lis[id]].push_back(make_pair(buf,i) ); } dfs2(root); for (int i = 0; i < q; i++){ printf("%d\n", outt[i] + 1); } return 0; }
/tmp/ccDhXupw.o: in function `neww()': a.cc:(.text+0x6): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/ccDhXupw.o a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/ccDhXupw.o a.cc:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/ccDhXupw.o /tmp/ccDhXupw.o: in function `ins(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': a.cc:(.text+0x4b): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccDhXupw.o a.cc:(.text+0x161): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/ccDhXupw.o /tmp/ccDhXupw.o: in function `main': a.cc:(.text+0x18b): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccDhXupw.o a.cc:(.text+0x192): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccDhXupw.o a.cc:(.text+0x26d): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccDhXupw.o a.cc:(.text+0x2ff): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/ccDhXupw.o a.cc:(.text+0x311): relocation truncated to fit: R_X86_64_PC32 against symbol `mp[abi:cxx11]' defined in .bss section in /tmp/ccDhXupw.o a.cc:(.text+0x395): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s456178213
p03974
C++
#include <bits/stdc++.h> using namespace std; struct st{ st *linkk[27]; st *up; int cnt; int belong; int att; st(){ for (int i = 0; i < 27; i++){ linkk[i] = NULL; } cnt = 0; } }; int n; int q; #define MAX 400002 char buf[MAX]; vector<string> v; st linkk2[MAX * 30]; int ord = 0; st *neww(){ ord++; return &linkk2[ord - 1]; } st *root; vector<st*> lis; void ins(string &a){ st *b = root; for (int i = 0; i < a.size(); i++){ if (b->linkk[a[i] - 'a'] == NULL){ b->linkk[a[i] - 'a'] = neww(); b->linkk[a[i] - 'a']->up = b; } b = b->linkk[a[i] - 'a']; } lis.push_back(b); } inline void dfs(st *b){ bool f = false; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ f = true; dfs(b->linkk[i]); b->cnt += b->linkk[i]->cnt; } } if (f == false){ b->cnt = 1; } } struct HL{ vector<int> bit[26][26]; st * pr; void resize(int b){ for (int i = 0; i < 26; i++){ for (int i1 = 0; i1 < 26; i1++){ bit[i][i1].assign(b + 2, 0); } } } void add(int i, int J,int j,int k){ bit[i][J][j] += k; } int sum(int i, int J,int j){ return bit[i][J][j]; } HL(st *pr_){ pr = pr_; } void done(){ for (int i = 0; i < 26; i++){ for (int jj = 0; jj < 26; jj++){ int siz = bit[i][jj].size(); for (int j = 1; j < siz; j++){ bit[i][jj][j] += bit[i][jj][j - 1]; } } } } }; vector<HL> hl; inline void dfs2(st *b, int belong, int att){ b->att = att; b->belong = belong; int id = -1; int mx = -1; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ if (mx < b->linkk[i]->cnt){ mx = b->linkk[i]->cnt; id = i; } } } if (mx == -1){ hl[belong].resize(att); return; } for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ if (i == id){ dfs2(b->linkk[i], belong, att + 1); } else{ hl.push_back(HL(b)); dfs2(b->linkk[i], hl.size() - 1, 0); } } } } inline void dfs3(st* b){ int A; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ if (b->linkk[i]->belong == b->belong){ A = i; } } } for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ if (b->belong != b->linkk[i]->belong){ hl[b->belong].add(A,i,b->att,b->linkk[i]->cnt); } dfs3(b->linkk[i]); } } } int gt(st *b){ b = b->up; int r = 0; while (b != NULL){ int belong = b->belong; int att = b->att; for (int i = 0; i < 26; i++){ for (int j = 0; j <i; j++){ r += hl[belong].sum(buf[i]-'a', buf[j]-'a',att); } } b = hl[belong].pr; } return r; } int main(){ root = neww(); root->up = NULL; cin >> n; for (int i = 0; i < n; i++){ scanf("%s", buf); v.push_back(buf); ins(v.back()); } dfs(root); hl.push_back(HL(NULL)); dfs2(root, 0, 0); dfs3(root); for (int i = 0; i < hl.size(); i++){ hl[i].done(); } int q; scanf("%d", &q); while (q--){ int id; scanf("%d", &id); id--; scanf("%s", buf); int ans = 0; ans += gt(lis[id]); ans++; printf("%d\n", ans); } return 0; }
/tmp/ccY0PNDe.o: in function `neww()': a.cc:(.text+0x6): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/ccY0PNDe.o a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/ccY0PNDe.o a.cc:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/ccY0PNDe.o /tmp/ccY0PNDe.o: in function `ins(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': a.cc:(.text+0x4b): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccY0PNDe.o a.cc:(.text+0x14e): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/ccY0PNDe.o /tmp/ccY0PNDe.o: in function `gt(st*)': a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `hl' defined in .bss section in /tmp/ccY0PNDe.o a.cc:(.text+0x22b): relocation truncated to fit: R_X86_64_PC32 against symbol `hl' defined in .bss section in /tmp/ccY0PNDe.o /tmp/ccY0PNDe.o: in function `main': a.cc:(.text+0x266): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccY0PNDe.o a.cc:(.text+0x26d): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccY0PNDe.o a.cc:(.text+0x351): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccY0PNDe.o a.cc:(.text+0x37e): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s734502475
p03974
C++
#include <iostream> #include <string> using namespace std; int main() { int tangoNum; cin >> tangoNum; string tango[tangoNum]; int temp[tangoNum]; int tempFlag[tangoNum];//とったかとってないか int kotae = 0; for (int i = 0; i < tangoNum; ++i) { cin >> tango[i]; tempFlag[i] = 0; } int qNum; string query[qNum]; int tangoFocus[qNum];//そのクエリーでの調べたい位置 for (int i = 0; i < qNum; ++i) { cin >> tangoFocus[i]; cin >> query[i]; } for (int i = 0; i < qNum; ++i) { for (int j = 0; j < tangoNum; ++j) { int temp[j][tango[j].size()]; for (int l = 0; l < tango[j].size(); ++l)//単語中のl文字目 { temp[j][l] = query[i].find(tango[j][l]); } } for (int j = 0; j < tango[tangoFocus[i]].size(); ++j)//focus単語の文字数,上から何文字目か { for (int l = 0; l < tangoNum; ++l)//l番目の文字列と,前からj番目の文字と比較 { if(temp[tangoFocus[i]][j]<temp[l][j] && tempFlag[l]==0 && l!=tangoFocus[i]){ kotae++; tempFlag[l] = 1; } } } cout << kotae << endl; for (int j = 0; j < tangoNum; ++j) { tempFlag[j] = 0; } kotae = 0; } return 0; }
a.cc: In function 'int main()': a.cc:39:39: error: invalid types 'int[int]' for array subscript 39 | if(temp[tangoFocus[i]][j]<temp[l][j] && tempFlag[l]==0 && l!=tangoFocus[i]){ | ^ a.cc:39:50: error: invalid types 'int[int]' for array subscript 39 | if(temp[tangoFocus[i]][j]<temp[l][j] && tempFlag[l]==0 && l!=tangoFocus[i]){ | ^
s762387845
p03974
C++
#include <iostream> #include <string> using namespace std; int main() { int tangoNum; cin >> tangoNum; string tango[tangoNum]; int temp[tangoNum]; int tempFlag[tangoNum];//とったかとってないか int kotae = 0; for (int i = 0; i < tangoNum; ++i) { cin >> tango[i]; tempFlag[i] = 0; } int qNum; string query[qNum]; int tangoFocus[qNum];//そのクエリーでの調べたい位置 for (int i = 0; i < qNum; ++i) { cin >> tangoFocus[i]; cin >> query[i]; } for (int i = 0; i < qNum; ++i) { for (int j = 0; j < tangoNum; ++j) { int temp[j][tango[j].size()]; for (int l = 0; l < tango[j].size(); ++l)//単語中の文字の位置 { temp[j][l] = find(query[i].begin(),query[i].end(), tango[j][l]); } } for (int j = 0; j < tango[tangoFocus[i]].size(); ++j)//focus単語の文字数,上から何文字目か { for (int l = 0; l < tangoNum; ++l)//l番目の文字列と,前からj番目の文字と比較 { if(temp[tangoFocus[i]][j]<temp[l][j] && tempFlag[l]==0 && l!=tangoFocus[i]){ kotae++; tempFlag[l] = 1; } } } cout << kotae << endl; for (int j = 0; j < tangoNum; ++j) { tempFlag[j] = 0; } kotae = 0; } return 0; }
a.cc: In function 'int main()': a.cc:32:34: error: no matching function for call to 'find(std::__cxx11::basic_string<char>::iterator, std::__cxx11::basic_string<char>::iterator, __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)' 32 | temp[j][l] = find(query[i].begin(),query[i].end(), tango[j][l]); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:32:34: note: '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >' is not derived from 'std::istreambuf_iterator<_CharT>' 32 | temp[j][l] = find(query[i].begin(),query[i].end(), tango[j][l]); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:39:39: error: invalid types 'int[int]' for array subscript 39 | if(temp[tangoFocus[i]][j]<temp[l][j] && tempFlag[l]==0 && l!=tangoFocus[i]){ | ^ a.cc:39:50: error: invalid types 'int[int]' for array subscript 39 | if(temp[tangoFocus[i]][j]<temp[l][j] && tempFlag[l]==0 && l!=tangoFocus[i]){ | ^
s858210177
p03974
C++
#include <iostream> #include <string> using namesqueryace std; int main() { int tangoNum; cin >> tangoNum; string tango[n]; int temp[tangoNum][]; int tempFlag[tangoNum];//とったかとってないか int kotae = 0; for (int i = 0; i < tangoNum; ++i) { cin >> tango[i]; tempFlag[i] = 0; } int qNum; string query[qNum]; int tangoFocus[qNum]; for (int i = 0; i < tangoNum; ++i) { cin >> k[i]; cin >> query[i]; } for (int i = 0; i < qNum; ++i) { for (int j = 0; j < tangoNum; ++j) { for (int l = 0; l < tango[j].size(); ++l)//単語中の文字の位置 { temp[j][l] = find(query[i].begin(),query[i].end(), tango[j][l]); } } for (int j = 0; j < tango[tangoFocus[i]].size(); ++j)//focus単語の文字数,上から何文字目か { for (int l = 0; l < tangoNum; ++l)//l番目の文字列と,前からj番目の文字と比較 { if(temp[tangoFocus[i]][j]<temp[l][j] && tempFlag[l]==0){ kotae++; tempFlag[l] = 1; } } } cout << kotae << endl; for (int j = 0; j < tangoNum; ++j) { tempFlag[j] = 0; } kotae = 0; } return 0; }
a.cc:3:7: error: expected nested-name-specifier before 'namesqueryace' 3 | using namesqueryace std; | ^~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 7 | cin >> tangoNum; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:8:5: error: 'string' was not declared in this scope 8 | string tango[n]; | ^~~~~~ a.cc:8:5: note: suggested alternatives: In file included from /usr/include/c++/14/iosfwd:41, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ In file included from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:9:9: error: declaration of 'temp' as multidimensional array must have bounds for all dimensions except the first 9 | int temp[tangoNum][]; | ^~~~ a.cc:14:16: error: 'tango' was not declared in this scope; did you mean 'tangoNum'? 14 | cin >> tango[i]; | ^~~~~ | tangoNum a.cc:18:11: error: expected ';' before 'query' 18 | string query[qNum]; | ^~~~~~ | ; a.cc:22:16: error: 'k' was not declared in this scope 22 | cin >> k[i]; | ^ a.cc:23:16: error: 'query' was not declared in this scope 23 | cin >> query[i]; | ^~~~~ a.cc:29:33: error: 'tango' was not declared in this scope; did you mean 'tangoNum'? 29 | for (int l = 0; l < tango[j].size(); ++l)//単語中の文字の位置 | ^~~~~ | tangoNum a.cc:31:17: error: 'temp' was not declared in this scope; did you mean 'tm'? 31 | temp[j][l] = find(query[i].begin(),query[i].end(), tango[j][l]); | ^~~~ | tm a.cc:31:35: error: 'query' was not declared in this scope 31 | temp[j][l] = find(query[i].begin(),query[i].end(), tango[j][l]); | ^~~~~ a.cc:31:30: error: 'find' was not declared in this scope; did you mean 'std::find'? 31 | temp[j][l] = find(query[i].begin(),query[i].end(), tango[j][l]); | ^~~~ | std::find In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: 'std::find' declared here 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ a.cc:34:29: error: 'tango' was not declared in this scope; did you mean 'tangoNum'? 34 | for (int j = 0; j < tango[tangoFocus[i]].size(); ++j)//focus単語の文字数,上から何文字目か | ^~~~~ | tangoNum a.cc:38:20: error: 'temp' was not declared in this scope; did you mean 'tm'? 38 | if(temp[tangoFocus[i]][j]<temp[l][j] && tempFlag[l]==0){ | ^~~~ | tm a.cc:44:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 44 | cout << kotae << endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:44:26: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 44 | cout << kotae << endl; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s546235572
p03974
C
#include<stdio.h> #include<stdlib.h> #define MAX 100001 #define max2(a,b) a<b?b:a #define max3(a,b,c) max2((max2(a,b)),c) #define max4(a,b,c,d) max3((max2(a,b)),c,d) struct DATA{ char s[400001]; int num; }d[MAX],tmp[MAX]; int my_strcmp(const void *s1,const void *s2){ int i; for(i = 0;*(str1 + i) == *(str2 + i);i++){ struct DATA d1 = *(struct DATA*)s1; struct DATA d2 = *(struct DATA*)s2; char str1[400001]; str1 = strcpy(str1,s1.s); char str2[400001]; str2 = strcpy(str2,s2.s); if(*(str1 + i) == '\0') return 0; } return *(str1 + i) - *(str2 + i); } int main(){ int i,j,k,l,m; int ans = 0; int min = 0; int tmp,t; int flag = 0; char qq['z'+1]={0}; char c; int n,q; int flag[400001]={0}; scanf("%d",&n); for(i = 0;i < n;i++){ scanf("%s",d[i].s); d.num = i+1; } scanf("%d",&q); for(i = 0;i < q;i++){ scanf("%d ",&k); for(j = 0;j < 26;j++){ scanf("%c",&c); qq[c]=j+'a'; } for(l = 1;l<n+1;l++){ strcpy(tmp[l].s,d[l].s); for(j = 0; tmp[l].[j]!='\0';j++){ tmp[l].[j] = qq[tmp[l].s[j]]; } } qsort(d, n, sizeof(struct DATA), strcmp); } printf("%d\n",ans); return 0; }
main.c: In function 'my_strcmp': main.c:16:15: error: 'str1' undeclared (first use in this function); did you mean 's1'? 16 | for(i = 0;*(str1 + i) == *(str2 + i);i++){ | ^~~~ | s1 main.c:16:15: note: each undeclared identifier is reported only once for each function it appears in main.c:16:30: error: 'str2' undeclared (first use in this function); did you mean 's2'? 16 | for(i = 0;*(str1 + i) == *(str2 + i);i++){ | ^~~~ | s2 main.c:20:18: error: implicit declaration of function 'strcpy' [-Wimplicit-function-declaration] 20 | str1 = strcpy(str1,s1.s); | ^~~~~~ main.c:3:1: note: include '<string.h>' or provide a declaration of 'strcpy' 2 | #include<stdlib.h> +++ |+#include <string.h> 3 | #define MAX 100001 main.c:20:18: warning: incompatible implicit declaration of built-in function 'strcpy' [-Wbuiltin-declaration-mismatch] 20 | str1 = strcpy(str1,s1.s); | ^~~~~~ main.c:20:18: note: include '<string.h>' or provide a declaration of 'strcpy' main.c:20:32: error: request for member 's' in something not a structure or union 20 | str1 = strcpy(str1,s1.s); | ^ main.c:22:32: error: request for member 's' in something not a structure or union 22 | str2 = strcpy(str2,s2.s); | ^ main.c: In function 'main': main.c:39:13: error: conflicting types for 'flag'; have 'int[400001]' 39 | int flag[400001]={0}; | ^~~~ main.c:35:13: note: previous definition of 'flag' with type 'int' 35 | int flag = 0; | ^~~~ main.c:44:18: error: '(struct DATA *)&d' is a pointer; did you mean to use '->'? 44 | d.num = i+1; | ^ | -> main.c:54:25: warning: incompatible implicit declaration of built-in function 'strcpy' [-Wbuiltin-declaration-mismatch] 54 | strcpy(tmp[l].s,d[l].s); | ^~~~~~ main.c:54:25: note: include '<string.h>' or provide a declaration of 'strcpy' main.c:54:35: error: subscripted value is neither array nor pointer nor vector 54 | strcpy(tmp[l].s,d[l].s); | ^ main.c:55:39: error: subscripted value is neither array nor pointer nor vector 55 | for(j = 0; tmp[l].[j]!='\0';j++){ | ^ main.c:55:43: error: expected identifier before '[' token 55 | for(j = 0; tmp[l].[j]!='\0';j++){ | ^ main.c:56:36: error: subscripted value is neither array nor pointer nor vector 56 | tmp[l].[j] = qq[tmp[l].s[j]]; | ^ main.c:56:40: error: expected identifier before '[' token 56 | tmp[l].[j] = qq[tmp[l].s[j]]; | ^ main.c:60:50: error: 'strcmp' undeclared (first use in this function) 60 | qsort(d, n, sizeof(struct DATA), strcmp); | ^~~~~~ main.c:60:50: note: 'strcmp' is defined in header '<string.h>'; this is probably fixable by adding '#include <string.h>'
s284696985
p03974
C++
#include <iostream> #include <vector> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <cstring> #include <queue> #include <algorithm> #include <climits> #include <string> #include <cstdlib> #include <sstream> #include <cmath> #include <cassert> #include <iomanip> // cout << setprecision(9) << fixed; using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> PII; typedef pair<long, long> PLL; #define umap unordered_map #define uset unordered_set #define pqueue priority_queue int main() { int N; cin >> N; vector<string> S(N); for (int j = 0; j < N; j++) { cin >> s[j]; } int Q; cin >> Q; vector<int> k(Q); vector<string> p(Q); for (int i = 0; i < Q; i++) { cin >> k[i] >> p[i]; } for (int i = 0; i < Q; i++) { string cp = s[k[i]]; for (int j = 0; j < cp.size(); j++) { cp[j] = p[i][cp[j] - 'a']; } int cnt = 1; for (int j = 0; j < N; j++) { if (j == k[i]) { continue; } string cps = s[j]; for (int j = 0; j < cps.size(); j++) { cps[j] = p[i][cps[j] - 'a']; } if (cps < cp) { cnt++; } } cout << cnt << endl; } return 0; }
a.cc: In function 'int main()': a.cc:34:16: error: 's' was not declared in this scope 34 | cin >> s[j]; | ^ a.cc:45:21: error: 's' was not declared in this scope 45 | string cp = s[k[i]]; | ^
s642650268
p03974
C++
#include <iostream> #include <vector> #include <string> #include <random> #include <algorithm> #include <unordered_map> #include <map> #include <list> #define DBG #ifdef DBG #define PRINT_TIME(s,e) cout << (double)(e-s) << " CLOCK" << endl #define LOOP for ( int i=0; i<MAXIMUM; i++ ) #define START start = clock(); #define END end = clock(); PRINT_TIME(start,end); #else #define PRINT_TIME(s,e) #define LOOP #define START #define END #endif using namespace std; int comp ( const char x, const char y, const array<char,26> dict ){ int xp = -1; int yp = -1; for( int i=0; i<26; i++ ){ if( x == dict[i] ){ xp = i; break; } } for( int i=0; i<26; i++ ){ if( y == dict[i] ){ yp = i; break; } } return xp - yp; } unsigned long compstr( const string x, const string y, const array<char,26> dict ) { for (int i = 0; i < min(x.length(), y.length()); i++) { if (x[i] == y[i]) continue; return comp(x[i], y[i],dict); } return x.length() + y.length() - y.length(); } int main(void) { #ifdef DBG static clock_t start,end; #else ios::sync_with_stdio(false); cin.tie(0); #endif int N; cin >> N; string S[N]; for( int i=0; i<N; i++ ){ cin >> S[i]; } long Q; cin >> Q; array<char,26> q; for( int aa=0; aa<Q; aa++ ){ int t[N]; for( int i=0; i<N; i++ ){ t[i] = i; } long k; string ql; cin >> k >> ql; for(int i=0; i<26; i++){ q[i] = ql[i]; } int temp; for (int i = 0; i < N - 1; i++) { for (int j = N - 1; j > i; j--) { if (compstr(S[t[i]],S[t[j]], q) > 0) { /* 前の要素の方が大きかったら */ temp = t[j]; /* 交換する */ t[j] = t[j - 1]; t[j - 1]= temp; } } } cout << t[k]+1 << endl; } } //inline int is
a.cc:26:61: error: 'dict' has incomplete type 26 | int comp ( const char x, const char y, const array<char,26> dict ){ | ~~~~~~~~~~~~~~~~~~~~~^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:99:12: note: declaration of 'struct std::array<char, 26>' 99 | struct array; | ^~~~~ a.cc:44:77: error: 'dict' has incomplete type 44 | unsigned long compstr( const string x, const string y, const array<char,26> dict ) { | ~~~~~~~~~~~~~~~~~~~~~^~~~ /usr/include/c++/14/bits/stl_pair.h:99:12: note: declaration of 'struct std::array<char, 26>' 99 | struct array; | ^~~~~ a.cc: In function 'int main()': a.cc:69:20: error: aggregate 'std::array<char, 26> q' has incomplete type and cannot be defined 69 | array<char,26> q; | ^ a.cc:9:1: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>' 8 | #include <list> +++ |+#include <array> 9 |
s651820890
p03974
C++
#include <bits/stdc++.h> using namespace std; int n; int q; #define MAX 400002 char buf[MAX]; vector<string> v; struct st{ st *linkk[27]; int cnt; int belong; int att; st(){ for (int i = 0; i < 27; i++){ linkk[i] = NULL; } cnt = 0; } }; st linkk[MAX * 40]; int ord = 0; st *neww(){ ord++; return &linkk[ord - 1]; } st *root = neww(); vector<st*> lis; void ins(string &a){ st *b = root; for (int i = 0; i < a.size(); i++){ if (b->linkk[a[i]-'a'] == NULL){ b->linkk[a[i] - 'a'] = neww(); } b = b->linkk[a[i] - 'a']; } lis.push_back(b); } inline void dfs(st *b){ b->cnt = 1; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ dfs(b->linkk[i]); b->cnt += b->linkk[i]->cnt; } } } struct HL{ vector<int> bit[26]; st * pr; void resize(int b){ for (int i = 0; i < 26; i++){ bit[i].assign(b+2, 0); } } HL(st *pr_){ pr = pr_; } }; vector<HL> hl; inline void dfs2(st *b,int belong,int att){ b->att = att; b->belong = belong; if (b->cnt == 1){ hl[belong].resize(att); return; } int id = -1; int mx = -1; for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ if (mx < b->linkk[i]->cnt){ mx = b->linkk[i]->cnt; id = i; } } } for (int i = 0; i < 26; i++){ if (b->linkk[i] != NULL){ if (i == id){ dfs2(b->linkk[i], belong, att + 1); } else{ hl.push_back(HL(b)); dfs2(b->linkk[i], hl.size() - 1, 0); } } } } int main(){ cin >> n; for (int i = 0; i < n; i++){ scanf("%s", buf); v.push_back(buf); ins(v.back()); } dfs(root); hl.push_back(HL(NULL)); dfs2(root, 0, 0); int q; scanf("%d", &q); while (q--){ int id; scanf("%d", &id); id--; scanf("%s", buf); } return 0; }
/tmp/cczro9GT.o: in function `neww()': a.cc:(.text+0x6): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/cczro9GT.o a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/cczro9GT.o a.cc:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against symbol `ord' defined in .bss section in /tmp/cczro9GT.o /tmp/cczro9GT.o: in function `ins(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': a.cc:(.text+0x43): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cczro9GT.o a.cc:(.text+0x113): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/cczro9GT.o /tmp/cczro9GT.o: in function `main': a.cc:(.text+0x20a): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cczro9GT.o a.cc:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `hl' defined in .bss section in /tmp/cczro9GT.o a.cc:(.text+0x255): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cczro9GT.o /tmp/cczro9GT.o: in function `__static_initialization_and_destruction_0()': a.cc:(.text+0x3b4): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/cczro9GT.o a.cc:(.text+0x3bb): relocation truncated to fit: R_X86_64_PC32 against symbol `lis' defined in .bss section in /tmp/cczro9GT.o a.cc:(.text+0x3d4): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s669208111
p03974
C
#include <stdio.h> #define MAXN (400000) class TrieNode { public: bool exist; int son_count; TrieNode* nodes[26]={0}; TrieNode():son_count(0),exist(false){} TrieNode * & getNode(const char & chr) { return nodes[chr-'a']; } }nodes[MAXN]; int nodes_cnt = 0; class Trie { public: Trie() { root = new TrieNode(); } void insert(const char * word) { TrieNode * now = root; while(*word) { now->son_count++; if(!now->getNode(*word)) now = now->getNode(*word) = &nodes[nodes_cnt++]; else now = now->getNode(*word); word++; } now->son_count ++; now->exist = true; } int get_rank(const char * word, const char * char_rank) { int rank = 1; TrieNode * now = root, *last = NULL, *tmp; while(*word) { for(int i = 0; char_rank[i] != *word; i++) { tmp = now->getNode(char_rank[i]); if(tmp) rank+= tmp->son_count; } last = now; now = now->getNode(*word); word++; if(*word && last->exist) rank++; } return rank; } private: TrieNode* root; }; #define MAX_CHAR_LEN (1000000) #define MAX_STR_CNT (400000+5) char char_buffer[MAX_CHAR_LEN]; char * str_table[MAX_STR_CNT]; int main() { int N,Q,k; char char_rank[32], * ptr = char_buffer; Trie trie; scanf("%d",&N); for(int i = 0; i < N; i++) { str_table[i] = ptr; scanf("%s",ptr); trie.insert(ptr); ptr += strlen(ptr) + 1; } scanf("%d",&Q); for(int i = 0; i < Q; i++) { scanf("%d%s", &k, char_rank); int rank = trie.get_rank(str_table[k-1], char_rank); printf("%d\n", rank); } //printf("%d") return 0; }
main.c:4:1: error: unknown type name 'class' 4 | class TrieNode { | ^~~~~ main.c:4:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token 4 | class TrieNode { | ^ main.c:14:2: warning: data definition has no type or storage class 14 | }nodes[MAXN]; | ^~~~~ main.c:14:2: error: type defaults to 'int' in declaration of 'nodes' [-Wimplicit-int] main.c:18:1: error: unknown type name 'class' 18 | class Trie { | ^~~~~ main.c:18:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token 18 | class Trie { | ^ main.c: In function 'main': main.c:71:5: error: unknown type name 'Trie' 71 | Trie trie; | ^~~~ main.c:77:13: error: request for member 'insert' in something not a structure or union 77 | trie.insert(ptr); | ^ main.c:78:16: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration] 78 | ptr += strlen(ptr) + 1; | ^~~~~~ main.c:2:1: note: include '<string.h>' or provide a declaration of 'strlen' 1 | #include <stdio.h> +++ |+#include <string.h> 2 | #define MAXN (400000) main.c:78:16: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch] 78 | ptr += strlen(ptr) + 1; | ^~~~~~ main.c:78:16: note: include '<string.h>' or provide a declaration of 'strlen' main.c:84:24: error: request for member 'get_rank' in something not a structure or union 84 | int rank = trie.get_rank(str_table[k-1], char_rank); | ^
s127929938
p03974
C++
#include <stdio.h> #define MAXN (400000) class TrieNode { public: bool exist; int son_count; TrieNode* nodes[26]={0}; TrieNode():son_count(0),exist(false){} TrieNode * & getNode(const char & chr) { return nodes[chr-'a']; } }nodes[MAXN]; int nodes_cnt = 0; class Trie { public: Trie() { root = new TrieNode(); } void insert(const char * word) { TrieNode * now = root; while(*word) { now->son_count++; if(!now->getNode(*word)) now = now->getNode(*word) = &nodes[nodes_cnt++]; else now = now->getNode(*word); word++; } now->son_count ++; now->exist = true; } int get_rank(const char * word, const char * char_rank) { int rank = 1; TrieNode * now = root, *last = NULL, *tmp; while(*word) { for(int i = 0; char_rank[i] != *word; i++) { tmp = now->getNode(char_rank[i]); if(tmp) rank+= tmp->son_count; } last = now; now = now->getNode(*word); word++; if(*word && last->exist) rank++; } return rank; } private: TrieNode* root; }; #define MAX_CHAR_LEN (1000000) #define MAX_STR_CNT (400000+5) char char_buffer[MAX_CHAR_LEN]; char * str_table[MAX_STR_CNT]; int main() { int N,Q,k; char char_rank[32], * ptr = char_buffer; Trie trie; scanf("%d",&N); for(int i = 0; i < N; i++) { str_table[i] = ptr; scanf("%s",ptr); trie.insert(ptr); ptr += strlen(ptr) + 1; } scanf("%d",&Q); for(int i = 0; i < Q; i++) { scanf("%d%s", &k, char_rank); int rank = trie.get_rank(str_table[k-1], char_rank); printf("%d\n", rank); } //printf("%d") return 0; }
a.cc: In function 'int main()': a.cc:78:16: error: 'strlen' was not declared in this scope 78 | ptr += strlen(ptr) + 1; | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <stdio.h> +++ |+#include <cstring> 2 | #define MAXN (400000)
s242993053
p03974
C++
#include <iostream> #include <string> #include <cstdio> #include <cstdlib> #include <map> #include <algorithm> using namespace std; struct Node { Node* next[26]; int count; bool flag; Node() { count= 0; flag = false; memset(next, 0, sizeof(next)); } }; int n, q, id; string s; string arr[100010]; Node* root; void insert(string s, Node* p) { for (int i = 0; i < s.length(); ++i) { if (NULL == p->next[s[i] - 'a']) { p->next[s[i] - 'a'] = new Node(); } p->next[s[i] - 'a']->count += 1; p = p->next[s[i] - 'a']; } p->flag = true; } void in() { cin >> n; root = new Node(); for (int i = 0; i < n; ++i) { cin >> s; arr[i] = s; insert(s, root); } } void run() { cin >> q; for (int i = 0; i < q; ++i) { cin >> id >> s; --id; int ans = 0; Node* p = root; for (int j = 0; j < arr[id].length(); ++j) { for (int k = 0; k < s.length(); ++k) { //cout << s[k] << ";"; if (s[k] == arr[id][j]) { break; } else { if (p->next[s[k] - 'a'] != NULL) { ans += p->next[s[k] - 'a']->count; } } } //cout << endl; p = p->next[arr[id][j] - 'a']; if (p->flag) { ans += 1; } } cout << ans << endl; } } void out() { } int main() { //freopen("data", "r", stdin); in(); run(); out(); return 0; }
a.cc: In constructor 'Node::Node()': a.cc:18:17: error: 'memset' was not declared in this scope 18 | memset(next, 0, sizeof(next)); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <algorithm> +++ |+#include <cstring> 7 |
s428067076
p03974
C++
#include<stdio.h> #include<cstring> #include<algorithm> #include<cstdlib> #include<cmath> #include<ctime> #include<set> #include<map> #include<vector> #define pii pair<int,int> #define fi first #define se second #define pb push_back #define SZ(x) ((int)((x).size())) #define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++) #define per(i,j,k) for(int i=(int)j;i>=(int)k;i--) using namespace std; typedef long long LL; typedef double DB; const DB pi=acos(-1.0); const int N=110000; int go[N<<2][26]; int node=1; int sz[N<<2]; int n,Q; struct query{ int id; char d[30]; }qq[N]; char str[1010000]; int tot=0; int st[N]; int ed[N]; int end[N<<2]; vector<int>que[N]; int ans[N]; int gtw[26][26]; int main(){ scanf("%d",&n); rep(i,1,n){ scanf("%s",str+tot+1); st[i]=tot+1; ed[i]=st[i]+strlen(str+st[i])-1; tot=ed[i]+3; int now=1; rep(j,st[i],ed[i]){ if(!go[now][str[j]-'a'])go[now][str[j]-'a']=++node; now=go[now][str[j]-'a']; sz[now]++; } end[now]++; } scanf("%d",&Q); rep(i,1,Q){ int k;scanf("%d",&k); scanf("%s",qq[i].d+1); que[k].pb(i); } rep(i,1,n){ memset(gtw,0,sizeof gtw); int now=1; int rr=0; rep(j,st[i],ed[i]){ int dd=str[j]-'a'; rep(k,0,25)if(go[now][k])if(k^dd){ gtw[dd][k]+=sz[go[now][k]]; } rr+=end[now]; now=go[now][dd]; } rep(j,0,que[i].size()-1){ int xx=que[i][j]; ans[xx]=1+rr; rep(d,0,25)rep(l,d+1,25) ans[xx]+=gtw[qq[xx].d[l]-'a'][qq[xx].d[d]-'a']; } } rep(i,1,Q)printf("%d\n",ans[i]); return 0; }
a.cc: In function 'int main()': a.cc:51:17: error: reference to 'end' is ambiguous 51 | end[now]++; | ^~~ In file included from /usr/include/c++/14/set:65, from a.cc:7: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/algorithmfwd.h:39, from /usr/include/c++/14/bits/stl_algo.h:59, from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:34:5: note: 'int end [440000]' 34 | int end[N<<2]; | ^~~ a.cc:69:29: error: reference to 'end' is ambiguous 69 | rr+=end[now]; | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:34:5: note: 'int end [440000]' 34 | int end[N<<2]; | ^~~
s607133598
p03975
C++
#include <stdio.h> int main(int n,int a,int b,int ans=0,int t[1001]){ scanf("%d%d%d",&n,&a,&b); for(int i=1; i<=n; i++) scanf("%d",&t[i]); for(int i=1; i<=n; i++) ans+=((t[i]<a||t[i]>=b)?1:0); printf("%d\n",ans); }
a.cc:2:5: warning: second argument of 'int main(int, int, int, int, int*)' should be 'char **' [-Wmain] 2 | int main(int n,int a,int b,int ans=0,int t[1001]){ | ^~~~ a.cc:2:5: warning: third argument of 'int main(int, int, int, int, int*)' should probably be 'char **' [-Wmain] a.cc:2:5: warning: 'int main(int, int, int, int, int*)' takes only zero or two arguments [-Wmain] a.cc:2:42: error: default argument missing for parameter 5 of 'int main(int, int, int, int, int*)' 2 | int main(int n,int a,int b,int ans=0,int t[1001]){ | ~~~~^~~~~~~ a.cc:2:32: note: ...following parameter 4 which has a default argument 2 | int main(int n,int a,int b,int ans=0,int t[1001]){ | ~~~~^~~~~
s997776180
p03975
C++
#include <stdio.h> int main(int n,int a,int b,int ans=0,int t[1001];){ scanf("%d%d%d",&n,&a,&b); for(int i=1; i<=n; i++) scanf("%d",&t[i]); for(int i=1; i<=n; i++) ans+=((t[i]<a||t[i]>=b)?1:0); printf("%d\n",ans); }
a.cc:2:49: error: expected ')' before ';' token 2 | int main(int n,int a,int b,int ans=0,int t[1001];){ | ~ ^ | ) a.cc:2:5: warning: second argument of 'int main(int, int, int, int, int*)' should be 'char **' [-Wmain] 2 | int main(int n,int a,int b,int ans=0,int t[1001];){ | ^~~~ a.cc:2:5: warning: third argument of 'int main(int, int, int, int, int*)' should probably be 'char **' [-Wmain] a.cc:2:5: warning: 'int main(int, int, int, int, int*)' takes only zero or two arguments [-Wmain] a.cc:2:42: error: default argument missing for parameter 5 of 'int main(int, int, int, int, int*)' 2 | int main(int n,int a,int b,int ans=0,int t[1001];){ | ~~~~^~~~~~~ a.cc:2:32: note: ...following parameter 4 which has a default argument 2 | int main(int n,int a,int b,int ans=0,int t[1001];){ | ~~~~^~~~~ a.cc:2:50: error: expected unqualified-id before ')' token 2 | int main(int n,int a,int b,int ans=0,int t[1001];){ | ^
s078351020
p03975
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n,a,b;cin>>n>>a>>b; int ans=0; rep(i,0,n){ int t;cin>>t; if(t<a||t>=b)ans++; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:6:7: error: 'i' was not declared in this scope 6 | rep(i,0,n){ | ^ a.cc:6:3: error: 'rep' was not declared in this scope 6 | rep(i,0,n){ | ^~~
s461454694
p03975
C++
#include<iostream> using namespace std; int main(){ int n , a , b , x,f; cin>>n>>a>>b; f = 0; for(int i = 0 ; i < n ; i++){ cin>>x; if(x>=b || x < a) f++ } cout<<f<<endl; return 0; }
a.cc: In function 'int main()': a.cc:11:38: error: expected ';' before '}' token 11 | if(x>=b || x < a) f++ | ^ | ; 12 | } | ~
s270120276
p03975
C++
#include <bits/stdc++.h> #include <fstream> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> //#define _debug #define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define sc(x) scanf("%d",&x) #define ll long long #define FOR(i,a,b) for(int i=a;i<b;i++) #define FORd(i,a,b) for(int i=a;i>b;i--) #define ff first #define ss second #define sz(x) x.size() #define pb push_back //#define _online_judge using namespace std; using namespace __gnu_pbds; typedef tree<int, //data type null_type, // less<int>, // rb_tree_tag, //red-black tree tree_order_statistics_node_update> new_data_set; typedef pair<int,int> pii; typedef vector<pii> vii; const int con = static_cast<const int>(1e4 + 5); const int MOD = 1000000007; int main(){ FASTIO; #ifdef _online_judge freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); #endif int n,a,b;cin >> n >> a >> b; int x,ans=0; FOR(i,0,n){ cin >> x; if(x =< a || x >= b) ans++; } cout << ans; }
a.cc: In function 'int main()': a.cc:44:15: error: expected primary-expression before '<' token 44 | if(x =< a || x >= b) ans++; | ^
s790690765
p03975
C++
#include <bits/stdc++.h> #include "../../../cpp/template/template.cpp" using namespace std; void solve(long long N, long long A, long long B, std::vector<long long> t){ int cnt = 0; rep(i,N){ if(t[i]<A || t[i]>=B) cnt++; } cout << cnt << endl; } int main(){ long long N; scanf("%lld",&N); long long A; scanf("%lld",&A); long long B; scanf("%lld",&B); std::vector<long long> t(N); for(int i = 0 ; i < N ; i++){ scanf("%lld",&t[i]); } solve(N, A, B, std::move(t)); return 0; }
a.cc:2:10: fatal error: ../../../cpp/template/template.cpp: No such file or directory 2 | #include "../../../cpp/template/template.cpp" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s337060661
p03975
C++
# -*- coding: utf-8 -*- def main(): n, a, b = map(int, input().split()) count = 0 for i in range(n): ti = int(input()) if a <= ti < b: pass else: count += 1 print(count) if __name__ == '__main__': main()
a.cc:1:3: error: invalid preprocessing directive #- 1 | # -*- coding: utf-8 -*- | ^ a.cc:19:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 19 | if __name__ == '__main__': | ^~~~~~~~~~ a.cc:4:1: error: 'def' does not name a type 4 | def main(): | ^~~
s994443669
p03975
C++
#include <vector> #include <iostream> #include <string> #include <map> #include <fstream> #include <sstream> #include <set> using namespace std; #define FOR(i,a,b) for(int i=a;i<b;i++) #define rep(i,b) FOR(i,0,b) #define INF mugen #define dump(x) cerr<<#x<<"="<<x<<endl #define all(a) (a).begin(),(a).end() typedef vector<int> vi; typedef vector<vi> vii; typedef vector<vii> viii; typedef pair<int,int> P; template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; } template <typename T> string to_string(const T &n){ostringstream stm;stm << n;return stm.str();} inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } using ll = long long; const ll mod = LLONG_MAX; vector<int> t; signed main(){ int N,A,B; cin>>N>>A>>B; rep(i,N){ int a; cin>>a;t.push_back(a); } int ans=0; for(auto itr:t){ if(itr<A || itr>=B )ans++; } cout<<ans<<endl; }
a.cc:23:16: error: 'LLONG_MAX' was not declared in this scope 23 | const ll mod = LLONG_MAX; | ^~~~~~~~~ a.cc:8:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 7 | #include <set> +++ |+#include <climits> 8 | using namespace std;
s616380565
p03975
C++
#include<bits/stdc++.h> int main() { int a,b,c,i,ans=0; cin>>a>>b>>c; int s[a]; for(i=0;i<a;i++) { cin>>s[i]; if(s[i]<b||s[i]>=c) ans++; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:5:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 5 | cin>>a>>b>>c; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:13:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 13 | cout<<ans<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:13:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 13 | cout<<ans<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s817602545
p03975
C++
#include <stdio.h> int main() { int a,b,c,i,ans=0;。 scanf("%d%d%d",&a,&b,&c); int s[a]; for(i=0;i<a;i++) { scanf("%d",&s[i]); if(s[i]<b||s[i]>=c) ans++; } printf("%d\n",ans); }
a.cc:4:23: error: extended character 。 is not valid in an identifier 4 | int a,b,c,i,ans=0;。 | ^ a.cc: In function 'int main()': a.cc:4:23: error: '\U00003002' was not declared in this scope 4 | int a,b,c,i,ans=0;。 | ^~