submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s332888229
p04003
C++
#include<bits/stdc++.h> using namespace std; #define MAX 1000005 #define pb push_back #define mp make_pair typedef pair<int,int> pi; int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; vector<pi> jie[MAX]; vector<int> shua[MAX]; bool vis[MAX]; inline int find(int x) { if(x==par[x]) return x; return par[x]=find(par[x]); } inline void inint(int x) { par[x]=x; rank[x]=0; } inline void unite(int x, int y) { x=find(x), y=find(y); if(x==y) return; if(rank[x]<rank[y]) { par[x]=y; return; } par[y]=x; if(rank[x]==rank[y]) rank[x]++; return; } int main() { memset(step, -1, sizeof(step)); scanf("%d %d", &N, &M); while(M--) { scanf("%d %d %d", &a, &b, &c); mx=max(mx, c); a--, b--, c--; jie[c].pb(mp(a, b)); } int yy=N; for(int i=0; i<mx; i++) { for(vector<pi>::iterator it=jie[i].begin(); it!=jie[i].end(); it++) { pi hh=*it; inint(hh.first); id[hh.first]=-1; vis[hh.first]=false; inint(hh.second); id[hh.second]=-1; vis[hh.second]=false; } for(vector<pi>::iterator it=jie[i].begin(); it!=jie[i].end(); it++) { pi hh=*it; unite(hh.first, hh.second); } for(vector<pi>::iterator it=jie[i].begin(); it!=jie[i].end(); it++) { pi hh=*it; if(!vis[hh.first]) { vis[hh.first]=true; int r=find(hh.first); if(id[r]==-1) id[r]=yy++; shua[id[r]].pb(hh.first); shua[hh.first].pb(id[r]); } swap(hh.first, hh.second); if(!vis[hh.first]) { vis[hh.first]=true; int r=find(hh.first); if(id[r]==-1) id[r]=yy++; shua[id[r]].pb(hh.first); shua[hh.first].pb(id[r]); } } } queue<int> q; q.push(0); step[0]=0; while(!q.empty()) { int t=q.front(); q.pop(); if(step[N-1]>-1) break; for(int i=0; i<shua[t].size(); i++) { if(step[shua[t][i]]==-1) { step[shua[t][i]]=step[t]+1; q.push(shua[t][i]); } } } if(step[N-1]==-1) printf("%d", -1); else printf("%d", step[N-1]/2); return 0; }
a.cc: In function 'void inint(int)': a.cc:22:9: error: reference to 'rank' is ambiguous 22 | rank[x]=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 /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, 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:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:29:12: error: reference to 'rank' is ambiguous 29 | 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:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~ a.cc:29:20: error: reference to 'rank' is ambiguous 29 | 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:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~ a.cc:35:12: error: reference to 'rank' is ambiguous 35 | 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:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~ a.cc:35:21: error: reference to 'rank' is ambiguous 35 | 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:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~ a.cc:36:17: error: reference to 'rank' is ambiguous 36 | rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~
s432992486
p04003
C++
//Written by Zhu Zeqi //Come on,baby //Hack,please #include<cmath> #include<math.h> #include<ctype.h> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<cwchar> #include<cwctype> #include<deque> #include<exception> #include<fstream> #include<functional> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<new> #include<numeric> #include<ostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<typeinfo> #include<utility> #include<valarray> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> const int INF=1e9+7; struct st{int p,b,c;}; bool operator < (const st &a,const st &b){return a.c>b.c;} int n,m; vector<int> g[100005]; map<int,int> d[100005]; map<int,vector<int> > ve[100005]; int main(){ //freopen("input.in","r",stdin); //freopen("output.out","w",stdout); scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ int u,v,w; scanf("%d%d%d",&u,&v,&w); u--;v--; ve[u][w].push_back(v); ve[v][w].push_back(u); g[u].push_back(w); g[v].push_back(w); } priority_queue<st> pq; pq.push((st){0,0,0}); d[0][0]=0; while(!pq.empty()){ st p=pq.top(); pq.pop(); if(d[p.p][p.b]!=p.c) continue; if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){ d[p.p][0]=p.c; pq.push((st){p.p,0,p.c}); } if(p.b==0){ for(int i=0;i<g[p.p].size();i++){ int v=g[p.p][i]; if(d[p.p].find(v)==d[p.p].end()||d[p.p][v]>p.c+1){ d[p.p][v]=p.c+1; pq.push((st){p.p,v,p.c+1}); } } continue; } for(int i=0;i<ve[p.p][p.b].size();i++){ int v=ve[p.p][p.b][i]; if(d[v].find(p.b)==d[v].end() || d[v][p.b]>p.c){ d[v][p.b]=p.c; pq.push((st){v,p.b,p.c}); } } } int ans=INF; for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second)); if(ans==INF) puts("-1"); else printf("%d\n",ans); printf("%d\n",ans); //system("pause"); return 0; }
a.cc:66:1: error: 'vector' does not name a type 66 | vector<int> g[100005]; | ^~~~~~ a.cc:67:1: error: 'map' does not name a type 67 | map<int,int> d[100005]; | ^~~ a.cc:68:1: error: 'map' does not name a type 68 | map<int,vector<int> > ve[100005]; | ^~~ a.cc: In function 'int main()': a.cc:77:17: error: 've' was not declared in this scope; did you mean 'v'? 77 | ve[u][w].push_back(v); | ^~ | v a.cc:79:17: error: 'g' was not declared in this scope 79 | g[u].push_back(w); | ^ a.cc:82:9: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'? 82 | priority_queue<st> pq; | ^~~~~~~~~~~~~~ | std::priority_queue In file included from /usr/include/c++/14/queue:66, from a.cc:45: /usr/include/c++/14/bits/stl_queue.h:496:11: note: 'std::priority_queue' declared here 496 | class priority_queue | ^~~~~~~~~~~~~~ a.cc:82:26: error: expected primary-expression before '>' token 82 | priority_queue<st> pq; | ^ a.cc:82:28: error: 'pq' was not declared in this scope 82 | priority_queue<st> pq; | ^~ a.cc:84:9: error: 'd' was not declared in this scope 84 | d[0][0]=0; | ^ a.cc:94:39: error: 'g' was not declared in this scope 94 | for(int i=0;i<g[p.p].size();i++){ | ^ a.cc:103:31: error: 've' was not declared in this scope 103 | for(int i=0;i<ve[p.p][p.b].size();i++){ | ^~ a.cc:112:13: error: 'map' was not declared in this scope 112 | for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second)); | ^~~ a.cc:112:13: note: suggested alternatives: In file included from /usr/include/c++/14/map:63, from a.cc:40: /usr/include/c++/14/bits/stl_map.h:102:11: note: 'std::map' 102 | class map | ^~~ /usr/include/c++/14/map:89:13: note: 'std::pmr::map' 89 | using map | ^~~ a.cc:112:17: error: expected primary-expression before 'int' 112 | for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second)); | ^~~ a.cc:112:54: error: 'it' was not declared in this scope; did you mean 'st'? 112 | for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second)); | ^~ | st a.cc:112:81: error: 'min' was not declared in this scope; did you mean 'std::min'? 112 | for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second)); | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:7: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~
s465734723
p04003
C++
//Written by Zhu Zeqi //Come on,baby //Hack,please #include<cmath> #include<math.h> #include<ctype.h> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<cwchar> #include<cwctype> #include<deque> #include<exception> #include<fstream> #include<functional> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<new> #include<numeric> #include<ostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<typeinfo> #include<utility> #include<valarray> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> #define CLR(x) memset(x,0,sizeof x) #define pb push_back #define mp make_pair #define F first #define S second #define pii pair<int,int> #define vi vector<int> #define MAX 1000000000000000000 #define MOD 1000000007 #define PI 3.141592653589793238462 #define INF 1000000000 typedef long long ll; //orz yht using namespace std; string i_s(int x){ if(x==0) return "0"; string ret=""; while(x){ ret=ret+(char)(x%10+'0'); x/=10; } reverse(ret.begin(),ret.end()); return ret; } string add(string a,string b){ if(a=="") a="0"; if(b=="") b="0"; if(a.length()<b.length()) swap(a,b); while(b.length()<a.length()){ b='0'+b; } for(int i=0;i<a.length();i++){ a[i]=a[i]+(b[i]-'0'); } bool big=false; for(int i=a.length()-1;i>=0;i--){ if(big){ a[i]++; } big=false; if(a[i]>'9'){ a[i]=a[i]-10; big=true; } } if(big) a='1'+a; return a; } string mul(string a,string b){ vector<int> va,vb; if(a=="0" || b=="0") return "0"; string ans; for(int i=0;i<a.length();i++){ va.push_back(a[i]-'0'); } for(int i=0;i<b.length();i++){ vb.push_back(b[i]-'0'); } reverse(va.begin(),va.end()); reverse(vb.begin(),vb.end()); vector<int> res; res.clear(); res.resize(1005); for(int i=0;i<a.length();i++){ for(int j=0;j<b.length();j++){ res[i+j]+=(va[i]*vb[j]); } } for(int i=0;i<1005;i++){ if(res[i]>9){ res[i+1]+=(res[i]/10); res[i]%=10; } } for(int i=0;i<1005;i++){ ans+=(res[i]+'0'); } reverse(ans.begin(),ans.end()); int k=0; while(ans[k]=='0'){ k++; } ans=ans.substr(k); return ans; } bool is_prime(int n){ if(n<2) return false; for(int i=2;i*i<=n;i++) if(n%i==0) return false; return true; } const int INF=1e9+7; struct st{int p,b,c;}; bool operator < (const st &a,const st &b){return a.c>b.c;} int n,m; vector<int> g[100005]; map<int,int> d[100005]; map<int,vector<int> > ve[100005]; int main(){ //freopen("input.in","r",stdin); //freopen("output.out","w",stdout); scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ int u,v,w; scanf("%d%d%d",&u,&v,&w); u--;v--; ve[u][w].push_back(v); ve[v][w].push_back(u); g[u].push_back(w); g[v].push_back(w); } priority_queue<st> pq; pq.push((st){0,0,0}); d[0][0]=0; while(!pq.empty()){ st p=pq.top(); pq.pop(); if(d[p.p][p.b]!=p.c) continue; if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){ d[p.p][0]=p.c; pq.push((st){p.p,0,p.c}); } if(p.b==0){ for(int i=0;i<g[p.p].size();i++){ int v=g[p.p][i]; if(d[p.p].find(v)==d[p.p].end()||d[p.p][v]>p.c+1){ d[p.p][v]=p.c+1; pq.push((st){p.p,v,p.c+1}); } } continue; } for(int i=0;i<ve[p.p][p.b].size();i++){ int v=ve[p.p][p.b][i]; if(d[v].find(p.b)==d[v].end() || d[v][p.b]>p.c){ d[v][p.b]=p.c; pq.push((st){v,p.b,p.c}); } } } int ans=INF; for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second)); if(ans==INF) puts("-1"); else printf("%d\n",ans); printf("%d\n",ans); //system("pause"); return 0; }
a.cc:69:13: error: expected unqualified-id before numeric constant 69 | #define INF 1000000000 | ^~~~~~~~~~ a.cc:158:11: note: in expansion of macro 'INF' 158 | const int INF=1e9+7; | ^~~
s096657037
p04003
C++
#include <iostream> #include <algorithm> #include <cmath> #include <stdio.h> #include <stdlib.h> #include <vector> #include <map> #include <queue> #include <set> #include <string> #include <string.h> #include <stack> #define Endl endl #define mp make_pair #define rep(N) for(int i=0;i<N;i++) #define repj(N) for(int j=0;j<N;j++) #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define For(I,N) for(int I=0;I<N;I++) #define cinone(N) int N;cin>>N; #define scanfone(N) int N;cin>>N; #define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm]; #define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]); #define over(A) {cout<<A<<endl;exit(0);} typedef unsigned long long ull; const int inf=1039704182; using namespace std; int n,m; vector <pii> vec[100005]; set <pair<pii,int> > squ; unordered_map <pii,int> dist; int main() { // freopen("input.txt","r",stdin); cin>>n>>m; int x,y,z; for(int i=0;i<m;i++) { scanf("%d%d%d",&x,&y,&z); x--; y--; vec[x].push_back(mp(y,z)); vec[y].push_back(mp(x,z)); } squ.insert(mp(mp(0,0),0));//distance, position and company. while(squ.size()) { int x=squ.begin()->first.second; int d=squ.begin()->first.first; int boss=squ.begin()->second; squ.erase(mp(mp(d,x),boss)); int c; if(boss==0) { for(int i=0;i<vec[x].size();i++) { c=vec[x][i].second; if(dist.find(mp(vec[x][i].first,c))==dist.end() || dist[mp(vec[x][i].first,c)]>d+1) { dist[mp(vec[x][i].first,c)]=d+1; squ.insert(mp(mp(d+1,vec[x][i].first),c)); } } } else { if(dist.find(mp(x,0))==dist.end() || dist[mp(x,0)]>d) { dist[mp(x,0)]=d; squ.insert(mp(mp(d,x),0)); } for(int i=0;i<vec[x].size();i++) { if(vec[x][i].second!=boss) continue; if(dist.find(mp(vec[x][i].first,boss))==dist.end() || dist[mp(vec[x][i].first,boss)]>d) { dist[mp(vec[x][i].first,boss)]=d; squ.insert(mp(mp(d,vec[x][i].first),boss)); } } } } int res=inf; for(int i=0;i<1000000;i++) { if(dist.find(mp(n-1,i))==dist.end()) continue; res=min(res,dist[mp(n-1,i)]); } cout<<(res==inf?-1:res)<<endl; return 0; }
a.cc:32:1: error: 'unordered_map' does not name a type 32 | unordered_map <pii,int> dist; | ^~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:60:36: error: 'dist' was not declared in this scope 60 | if(dist.find(mp(vec[x][i].first,c))==dist.end() || dist[mp(vec[x][i].first,c)]>d+1) | ^~~~ a.cc:69:28: error: 'dist' was not declared in this scope 69 | if(dist.find(mp(x,0))==dist.end() || dist[mp(x,0)]>d) | ^~~~ a.cc:77:36: error: 'dist' was not declared in this scope 77 | if(dist.find(mp(vec[x][i].first,boss))==dist.end() || dist[mp(vec[x][i].first,boss)]>d) | ^~~~ a.cc:88:20: error: 'dist' was not declared in this scope 88 | if(dist.find(mp(n-1,i))==dist.end()) continue; | ^~~~ a.cc:89:29: error: 'dist' was not declared in this scope 89 | res=min(res,dist[mp(n-1,i)]); | ^~~~
s439379411
p04003
C++
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <unordered_map> #include <queue> #define inf 0x3F3F3F3F using namespace std; struct Node { mutable int x,c,cost; operator int&()const{return cost;} }; priority_queue<Node,vector<Node>,greater<Node> >q; unordered_map<int,vector<int> >e[100005]; unordered_map<int,int>d[100005]; vector<int>g[100005]; int main(void) { int i,x,y,c,cost,n,m,k,ans=inf; scanf("%d%d%d",&n,&m,&k); for(i=1;i<=m;++i) { scanf("%d%d%d",&x,&y,&c); e[x][c].push_back(y); e[y][c].push_back(x); g[x].push_back(c); g[y].push_back(c); } d[0][0]=0;q.push((Node){0,0,0}); while(!q.empty()) { x=q.top().x;c=q.top().c;cost=q.top().cost;q.pop(); if(d[x][c]!=cost)continue; if(d[x].find(0)==d[x].end()||d[x][0]>cost) { d[x][0]=cost;q.push((Node){x,0,cost}); } if(c==0) { for(i=0;i<g[x].size();++i) { y=g[x][i]; if(d[x].find(y)==d[x].end()||d[x][y]>cost+1) { d[x][y]=cost+1;q.push((Node){x,y,cost+1}); } } continue; } for(i=0;i<e[x][c].size();++i) { y=e[x][c][i]; if(d[y].find(c)==d[y].end()||d[y][c]>cost) { d[y][c]=cost;q.push((Node){y,c,cost}); } } } for(i=0;i<d[n].size();++i)ans=min(ans,d[n][i].second); if(ans!=inf)printf("%d\n",ans); else printf("-1\n"); return 0; }
a.cc: In function 'int main()': a.cc:61:55: error: request for member 'second' in 'd[n].std::unordered_map<int, int>::operator[](i)', which is of non-class type 'std::unordered_map<int, int>::mapped_type' {aka 'int'} 61 | for(i=0;i<d[n].size();++i)ans=min(ans,d[n][i].second); | ^~~~~~
s919707659
p04003
C++
#include <map> #include <queue> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 2e6 + 5; queue <int> que; int n, m, dis[maxn]; vector <int> g[maxn], all[maxn]; unordered_map <int, vector <int> > g1[maxn]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i ++) { int u, v, c; scanf("%d%d%d", &u, &v, &c); u --; v --; g1[u][c].push_back(v); g1[v][c].push_back(u); all[c].push_back(u); all[c].push_back(v); } int cc = n; for (int c = 1; c <= 1000000; c ++) { sort(all[c].begin(), all[c].end()); all[c].erase(unique(all[c].begin(), all[c].end()), all[c].end()); for (int i = 0; i < (int) all[c].size(); i ++) { if (dis[all[c][i]] == c) continue; que.push(all[c][i]); while (!que.empty()) { int u = que.front(); que.pop(); dis[u] = c; g[u].push_back(cc); g[cc].push_back(u); for (int i = 0; i < (int) g1[u][c].size(); i ++) { int v = g1[u][c][i]; if (dis[v] != c) { que.push(v); } } } cc ++; } } memset(dis, -1, sizeof dis); dis[0] = 0; que.push(0); while (!que.empty()) { int u = que.front(); que.pop(); for (int i = 0; i < (int) g[u].size(); i ++) { int v = g[u][i]; if (!~dis[v]) { dis[v] = dis[u] + 1; que.push(v); } } } printf("%d\n", !~dis[n - 1] ? -1 : dis[n - 1] / 2); return 0; }
a.cc:14:1: error: 'unordered_map' does not name a type 14 | unordered_map <int, vector <int> > g1[maxn]; | ^~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:22:17: error: 'g1' was not declared in this scope; did you mean 'g'? 22 | g1[u][c].push_back(v); | ^~ | g a.cc:39:59: error: 'g1' was not declared in this scope; did you mean 'g'? 39 | for (int i = 0; i < (int) g1[u][c].size(); i ++) { | ^~ | g
s143029046
p04003
C++
#include<iostream> #include<cstdio> #include<vector> #include<queue> #include<cstring> #define pb push_back #define mp make_pair #define pii pair<int,int> #define inf 1e9+7 using namespace std; int n,m,dist[300005],hash[300005]={}; vector<pii > g[100005],gg[300005];//first:val vector<int> col[200005]; priority_queue<pii >q; void dfs(int s,int col,int now){ hash[s]=col; gg[s].pb(mp(1,now)); gg[now].pb(mp(0,s)); for(int i=0;i<g[s].size();i++) if(g[s][i].first==col&&hash[g[s][i].second]!=col) dfs(g[s][i].second,col,now); } void dij(){ q.push(mp(0,1)); memset(hash,0,sizeof(hash)); for(int i=1;i<=m+n;i++) dist[i]=inf; dist[1]=0; while(!q.empty()){ int v=q.top().second; q.pop(); if(v==n) return; if(hash[v]==0){ hash[v]=1; for(int i=0;i<gg[v].size();i++) if(dist[v]+gg[v][i].first<dist[gg[v][i].second]){ dist[gg[v][i].second]=dist[v]+gg[v][i].first; q.push(mp(-dist[gg[v][i].second],gg[v][i].second)); } } } } int main(){ freopen("ini.txt","r",stdin); scanf("%d%d",&n,&m); for(int i=1;i<=m;i++){ int f,r,val; scanf("%d%d%d",&f,&r,&val); g[f].pb(mp(val,r)); g[r].pb(mp(val,f)); col[val].pb(f); col[val].pb(r); } int now=n+1; for(int i=1;i<=m;i++) for(int j=0;j<col[i].size();j++) if(hash[col[i][j]]!=i){ dfs(col[i][j],i,now); now++; } dij(); if(dist[n]==inf) puts("-1"); else printf("%d\n",dist[n]); return 0; }
a.cc: In function 'void dfs(int, int, int)': a.cc:16:9: error: reference to 'hash' is ambiguous 16 | hash[s]=col; | ^~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, 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/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:22: note: 'int hash [300005]' 11 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:20:32: error: reference to 'hash' is ambiguous 20 | if(g[s][i].first==col&&hash[g[s][i].second]!=col) dfs(g[s][i].second,col,now); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:22: note: 'int hash [300005]' 11 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc: In function 'void dij()': a.cc:24:16: error: reference to 'hash' is ambiguous 24 | memset(hash,0,sizeof(hash)); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:22: note: 'int hash [300005]' 11 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:24:30: error: reference to 'hash' is ambiguous 24 | memset(hash,0,sizeof(hash)); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:22: note: 'int hash [300005]' 11 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:31:20: error: reference to 'hash' is ambiguous 31 | if(hash[v]==0){ | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:22: note: 'int hash [300005]' 11 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:32:25: error: reference to 'hash' is ambiguous 32 | hash[v]=1; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:22: note: 'int hash [300005]' 11 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc: In function 'int main()': a.cc:55:12: error: reference to 'hash' is ambiguous 55 | if(hash[col[i][j]]!=i){ | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:22: note: 'int hash [300005]' 11 | int n,m,dist[300005],hash[300005]={}; | ^~~~
s581816695
p04003
C++
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define pii pair<int,int> #define inf 1e9+7 using namespace std; int n,m,dist[300005],hash[300005]={}; vector<pii > g[100005],gg[300005];//first:val vector<int> col[200005]; priority_queue<pii >q; void dfs(int s,int col,int now){ hash[s]=col; gg[s].pb(mp(1,now)); gg[now].pb(mp(0,s)); for(int i=0;i<g[s].size();i++) if(g[s][i].first==col&&hash[g[s][i].second]!=col) dfs(g[s][i].second,col,now); } void dij(){ q.push(mp(0,1)); memset(hash,0,sizeof(hash)); for(int i=1;i<=m+n;i++) dist[i]=inf; dist[1]=0; while(!q.empty()){ int v=q.top().second; q.pop(); if(v==n) return; if(hash[v]==0){ hash[v]=1; for(int i=0;i<gg[v].size();i++) if(dist[v]+gg[v][i].first<dist[gg[v][i].second]){ dist[gg[v][i].second]=dist[v]+gg[v][i].first; q.push(mp(-dist[gg[v][i].second],gg[v][i].second)); } } } } int main(){ freopen("ini.txt","r",stdin); scanf("%d%d",&n,&m); for(int i=1;i<=m;i++){ int f,r,val; scanf("%d%d%d",&f,&r,&val); g[f].pb(mp(val,r)); g[r].pb(mp(val,f)); col[val].pb(f); col[val].pb(r); } int now=n+1; for(int i=1;i<=m;i++) for(int j=0;j<col[i].size();j++) if(hash[col[i][j]]!=i){ dfs(col[i][j],i,now); now++; } dij(); if(dist[n]==inf) puts("-1"); else printf("%d\n",dist[n]); return 0; }
a.cc: In function 'void dfs(int, int, int)': a.cc:12:9: error: reference to 'hash' is ambiguous 12 | hash[s]=col; | ^~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, 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/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:16:32: error: reference to 'hash' is ambiguous 16 | if(g[s][i].first==col&&hash[g[s][i].second]!=col) dfs(g[s][i].second,col,now); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc: In function 'void dij()': a.cc:20:16: error: reference to 'hash' is ambiguous 20 | memset(hash,0,sizeof(hash)); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:20:30: error: reference to 'hash' is ambiguous 20 | memset(hash,0,sizeof(hash)); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:27:20: error: reference to 'hash' is ambiguous 27 | if(hash[v]==0){ | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:28:25: error: reference to 'hash' is ambiguous 28 | hash[v]=1; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc: In function 'int main()': a.cc:51:12: error: reference to 'hash' is ambiguous 51 | if(hash[col[i][j]]!=i){ | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~
s076795113
p04003
C++
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define pii pair<int,int> #define inf 1e9+7 using namespace std; int n,m,dist[300005],hash[300005]={}; vector<pii > g[100005],gg[300005];//first:val vector<int> col[200005]; priority_queue<pii >q; void dfs(int s,int col,int now){ hash[s]=col; gg[s].pb(mp(1,now)); gg[now].pb(mp(0,s)); for(int i=0;i<g[s].size();i++) if(g[s][i].first==col&&hash[g[s][i].second]!=col) dfs(g[s][i].second,col,now); } void dij(){ q.push(mp(0,1)); memset(hash,0,sizeof(hash)); for(int i=1;i<=m+n;i++) dist[i]=inf; dist[1]=0; while(!q.empty()){ int v=q.top().second; q.pop(); if(v==n) return; if(hash[v]==0){ hash[v]=1; for(int i=0;i<gg[v].size();i++) if(dist[v]+gg[v][i].first<dist[gg[v][i].second]){ dist[gg[v][i].second]=dist[v]+gg[v][i].first; q.push(mp(-dist[gg[v][i].second],gg[v][i].second)); } } } } int main(){ freopen("ini.txt","r",stdin); scanf("%d%d",&n,&m); for(int i=1;i<=m;i++){ int f,r,val; scanf("%d%d%d",&f,&r,&val); g[f].pb(mp(val,r)); g[r].pb(mp(val,f)); col[val].pb(f); col[val].pb(r); } int now=n+1; for(int i=1;i<=m;i++) for(int j=0;j<col[i].size();j++) if(hash[col[i][j]]!=i){ dfs(col[i][j],i,now); now++; } dij(); if(dist[n]==inf) puts("-1"); else printf("%d\n",dist[n]); return 0; }
a.cc: In function 'void dfs(int, int, int)': a.cc:12:9: error: reference to 'hash' is ambiguous 12 | hash[s]=col; | ^~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, 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/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:16:32: error: reference to 'hash' is ambiguous 16 | if(g[s][i].first==col&&hash[g[s][i].second]!=col) dfs(g[s][i].second,col,now); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc: In function 'void dij()': a.cc:20:16: error: reference to 'hash' is ambiguous 20 | memset(hash,0,sizeof(hash)); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:20:30: error: reference to 'hash' is ambiguous 20 | memset(hash,0,sizeof(hash)); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:27:20: error: reference to 'hash' is ambiguous 27 | if(hash[v]==0){ | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc:28:25: error: reference to 'hash' is ambiguous 28 | hash[v]=1; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~ a.cc: In function 'int main()': a.cc:51:12: error: reference to 'hash' is ambiguous 51 | if(hash[col[i][j]]!=i){ | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:7:22: note: 'int hash [300005]' 7 | int n,m,dist[300005],hash[300005]={}; | ^~~~
s262924082
p04003
C++
#include <iostream> #include <algorithm> #include <math.h> #include <string.h> #include <cstdio> #include <vector> #include <set> #include <cassert> #include <cstdlib> #include <complex> #include <cctype> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <map> #include <set> #include <sstream> #include <functional> #include <iomanip> //#include <windows.h> //Should be deleted when using AtCoder&POJ using namespace std; #define ll long long #define pii pair<int,int> /**==Info== *Program:1 *Problem:すぬけ君の地下鉄旅行 / Snuke's Subway Trip *Date:2018-7-14 *Algorithm:BFS Tourist's *Stats:Unknown*/ bool debug=false; template<typename T> struct undispose_queue{ vector<T> v; int s; undispose_queue(){ s=0; v.clear(); } void push(T value){ v.push_back(value); } void pop(){ s++; } T front(){ return v[s]; } void clear(){ v.clear(); s=0; } bool empty(){ return s==v.size(); } int size(){ return v.size()-s; } vector<T> getData(){ return v; } }; const int A=2e6+1; const int B=2e5+1; int n,m; map<int,vector<int>> nei[B]; int col[B]; set<int> cols; vector<int> on[A]; vector<int> nnei[A]; int dis[A]; int main(int argc,char* argv[]){ scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ int a,b,c; scanf("%d%d%d",&a,&b,&c); a--;b--; nei[a][c].push_back(b); nei[b][c].push_back(a); on[c].push_back(a); on[c].push_back(b); cols.insert(c); } if(debug)cout<<"ok"<<endl; memset(col,-1,sizeof(col)); int stpos=n; for(set<int>::iterator it=cols.begin();it!=cols.end();it++){ int thscol=*it; if(debug)cout<<thscol<<endl; for(int i=0;i<on[thscol].size();i++){ int thspos=on[thscol][i]; if(col[thspos]==thscol){ continue; //In the same block } undispose_queue<int> uq; col[thspos]=thscol; uq.push(thspos); while(!uq.empty()){ int last=uq.front(); uq.pop(); for(int j=0;j<nei[last][thscol].size();j++){ int nxtpos=nei[last][thscol][j]; if(col[nxtpos]!=thscol){ col[nxtpos]=thscol; uq.push(nxtpos); } } } vector<int> v=uq.getData(); for(int j=0;j<v.size();j++){ nnei[v[j]].push_back(stpos); nnei[stpos].push_back(v[j]); if(debug)cout<<"connected "<<v[j]<<" and "<<stpos<<endl; } stpos++; } } if(debug)cout<<"bfs"<<endl; queue<int> q; fill(dis,dis+FUCK,-2); dis[0]=0; q.push(0); while(!q.empty()){ int last=q.front(); q.pop(); for(int i=0;i<nnei[last].size();i++){ if(dis[nnei[last][i]]==-2){ dis[nnei[last][i]]=dis[last]+1; q.push(nnei[last][i]); } } } cout<<dis[n-1]/2; return 0; }
a.cc: In function 'int main(int, char**)': a.cc:157:22: error: 'FUCK' was not declared in this scope 157 | fill(dis,dis+FUCK,-2); | ^~~~
s314251401
p04003
C++
#include <iostream> #include <algorithm> #include <math.h> #include <string.h> #include <cstdio> #include <vector> #include <set> #include <cassert> #include <cstdlib> #include <complex> #include <cctype> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <map> #include <set> #include <sstream> #include <functional> #include <iomanip> //#include <windows.h> //Should be deleted when using AtCoder&POJ using namespace std; #define ll long long #define pii pair<int,int> /**==Info== *Program:1 *Problem:すぬけ君の地下鉄旅行 / Snuke's Subway Trip *Date:2018-7-14 *Algorithm:BFS Tourist's *Stats:Unknown*/ bool debug=false; template<typename T> struct undispose_queue{ vector<T> v; int s; undispose_queue(){ s=0; v.clear(); } void push(T value){ v.push_back(value); } void pop(){ s++; } T front(){ return v[s]; } void clear(){ v.clear(); s=0; } bool empty(){ return s==v.size(); } int size(){ return v.size()-s; } vector<T> getData(){ return v; } }; int FUCK=2e6+1; int n,m; map<int,vector<int>> nei[FUCK]; int col[FUCK]; set<int> cols; vector<int> on[FUCK]; vector<int> nnei[FUCK]; int dis[FUCK]; int main(int argc,char* argv[]){ scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ int a,b,c; scanf("%d%d%d",&a,&b,&c); a--;b--; nei[a][c].push_back(b); nei[b][c].push_back(a); on[c].push_back(a); on[c].push_back(b); cols.insert(c); } if(debug)cout<<"ok"<<endl; memset(col,-1,sizeof(col)); int stpos=n; for(set<int>::iterator it=cols.begin();it!=cols.end();it++){ int thscol=*it; if(debug)cout<<thscol<<endl; for(int i=0;i<on[thscol].size();i++){ int thspos=on[thscol][i]; if(col[thspos]==thscol){ continue; //In the same block } undispose_queue<int> uq; col[thspos]=thscol; uq.push(thspos); while(!uq.empty()){ int last=uq.front(); uq.pop(); for(int j=0;j<nei[last][thscol].size();j++){ int nxtpos=nei[last][thscol][j]; if(col[nxtpos]!=thscol){ col[nxtpos]=thscol; uq.push(nxtpos); } } } vector<int> v=uq.getData(); for(int j=0;j<v.size();j++){ nnei[v[j]].push_back(stpos); nnei[stpos].push_back(v[j]); if(debug)cout<<"connected "<<v[j]<<" and "<<stpos<<endl; } stpos++; } } if(debug)cout<<"bfs"<<endl; queue<int> q; fill(dis,dis+2*n,-2); dis[0]=0; q.push(0); while(!q.empty()){ int last=q.front(); q.pop(); for(int i=0;i<nnei[last].size();i++){ if(dis[nnei[last][i]]==-2){ dis[nnei[last][i]]=dis[last]+1; q.push(nnei[last][i]); } } } cout<<dis[n-1]/2; return 0; }
a.cc:79:26: error: size of array 'nei' is not an integral constant-expression 79 | map<int,vector<int>> nei[FUCK]; | ^~~~ a.cc:81:9: error: size of array 'col' is not an integral constant-expression 81 | int col[FUCK]; | ^~~~ a.cc:84:16: error: size of array 'on' is not an integral constant-expression 84 | vector<int> on[FUCK]; | ^~~~ a.cc:86:18: error: size of array 'nnei' is not an integral constant-expression 86 | vector<int> nnei[FUCK]; | ^~~~ a.cc:88:9: error: size of array 'dis' is not an integral constant-expression 88 | int dis[FUCK]; | ^~~~
s805952196
p04003
C++
#include <iostream> #include <vector> #include <map> #include <unordered_map> #include <queue> #include <set> using namespace std; typedef long long ll; typedef pair<int, int> P; vector<P> edge2[100010]; vector<int> edge[400010]; unordered_map<P, int> mp; queue<int> que; int cost[400010]; int index; queue<int> que2[200010]; void bfs(){ while(!que.empty()){ int v = que.front(); que.pop(); for(int i = 0; i < edge[v].size(); i++){ int v2 = edge[v][i]; if(cost[v2] > cost[v]+1){ cost[v2] = cost[v]+1; que.push(v2); } } } } void dfs(int index, int p, int c, int prior){ mp[P(p, c)] = index; edge[p].push_back(index); edge[index].push_back(p); for(int i = 0; i < edge2[p].size(); i++){ if(edge2[p][i].first == prior) continue; if(edge2[p][i].second != c) continue; if(mp.find(edge2[p][i]) == mp.end()){ dfs(mp[P(p, c)], edge2[p][i].first, c, p); } } } int main(){ int N, M; cin >> N >> M; index = N; for(int i = 0; i < M; i++){ int p, q, c; cin >> p >> q >> c; p--; q--; c--; edge2[p].push_back(P(q, c)); edge2[q].push_back(P(p, c)); } for(int i = 0; i < N; i++){ for(int j = 0; j < edge2[i].size(); j++) { if(mp.find(P(i, edge2[i][j].second)) == mp.end()){ dfs(index, 0, edge2[i][j].second, -1); } } } for(int i = 0; i < N + index; i++){ cost[i] = 100000000; } cost[0] = 0; que.push(0); bfs(); if(cost[N-1] == 100000000){ cout << -1 << endl; } else{ cout << cost[N-1]/2 << endl; } return 0; }
a.cc:15:23: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 15 | unordered_map<P, int> mp; | ^~ In file included from /usr/include/c++/14/unordered_map:41, from a.cc:4: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, 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/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::pair<in
s467263254
p04003
C++
#include <iostream> #include <vector> #include <queue> #include <utility> #include <map> #define mp make_pair #define pb push_back using namespace std; int n, m, p[300000], q[300000], c[300000], ans[300000], nodeans[300000], expanded[300000]; vector< vector<int> > graph(300000); map< pair<int, int>, int> m1; vector< vector< pair<int, int> > > c_edge(1100000); int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 0; i < m; i++) { cin >> p[i] >> q[i] >> c[i]; graph[p[i]].push_back(i); graph[q[i]].push_back(i); c_edge[c[i]].push_back(make_pair(p[i], q[i])); c_edge[c[i]].push_back(make_pair(q[i], p[i])); ans[i] = 1e9; m1[mp(p[i], c[i])] = 1e9; m1[mp(q[i], c[i])] = 1e9; } for (int i = 1; i <= 1e6; i++) sort(c_edge[i].begin(), c_edge[i].end()); for (int i = 1; i <= n; i++) { nodeans[i] = 1e6; m1[mp(i, 0)] = 1e9; } priority_queue< pair<int, pair<int, int> > > pq; pq.push(mp(-1, mp(1, 0))); m1[mp(1, 0)] = 1; while (!pq.empty()) { pair<int, pair<int, int> > temp = pq.top(); pq.pop(); int node = temp.second.first, mode = temp.second.second; //cout << temp.first << " " << temp.second.first << " " << temp.second.second << endl; if (-temp.first != m1[mp(node, mode)]) { continue; } nodeans[node] = min(nodeans[node], -temp.first); if (node == n) break; if (mode == 0) { for (int i = 0; i < graph[node].size(); i++) { int edgenum = graph[node][i]; if (m1[mp(node, c[edgenum])] < -temp.first) continue; int node2 = p[edgenum]; if (node2 == node) node2 = q[edgenum]; if (m1[mp(node2, c[edgenum])] > -temp.first) { m1[mp(node2, c[edgenum])] = -temp.first; pq.push(mp(temp.first, mp(node2, c[edgenum]))); } if (m1[mp(node2, 0)] > -temp.first+1) { m1[mp(node2, 0)] = -temp.first+1; pq.push(mp(temp.first-1, mp(node2, 0))); } } } else { int index = lower_bound(c_edge[mode].begin(), c_edge[mode].end(), mp(node, -1)) - c_edge[mode].begin(); while (index < c_edge[mode].size()) { pair<int, int> temp2 = c_edge[mode][index++]; if (temp2.first != node) break; if (m1[mp(temp2.second, mode)] > -temp.first) { m1[mp(temp2.second, mode)] = -temp.first; pq.push(mp(temp.first, mp(temp2.second, mode))); } if (m1[mp(temp2.second, 0)] > -temp.first+1) { m1[mp(temp2.second, 0)] = -temp.first + 1; pq.push(mp(temp.first - 1, mp(temp2.second, 0))); } } } } if (nodeans[n] == 1e6) nodeans[n] = -1; cout << nodeans[n] << endl; }
a.cc: In function 'int main()': a.cc:30:17: error: 'sort' was not declared in this scope; did you mean 'short'? 30 | sort(c_edge[i].begin(), c_edge[i].end()); | ^~~~ | short
s376935064
p04003
C++
#include "bits/stdc++.h" #define ll long long #define rep2(i,a,b) for(int i=(a);i<=(b);++i) #define rep(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> #define ti3 tuple<int,int,int> int MOD=1000000000+7; int INF=1e6; using namespace std; string alphabet("abcdefghijklmnopqrstuvwxyz"); main(){ int n,m,visited[110000]={}; queue<pii> v[110000]; cin>>n>>m; rep(i,m){ int a,b,c; cin>>a>>b>>c; v[a].push({b,c}); v[b].push({a,c}); } int num=1; queue<int> now; now.push(1); visited[1]=1; while(!now.empty()){ int t=now.size(); rep(i,t){ int a=now.front(); now.pop(); int s=v[a].size(); rep(j,s){ int d=v[a].front().first; int c=v[a].front().second.first; v[a].pop(); visited[d]=1; now.push(d); queue<int> q; q.push(d); while(!q.empty()){ int f=q.front(); q.pop(); int h=v[f].size(); rep(ii,v[f].size()){ if(v[f].front().second==c){ if(!visited[v[f].front().first]) now.push(v[f].front().first); q.push(v[f].front().first); visited[v[f].front().first]=1; v[f].pop(); } else{ v[f].push(v[f].front()); v[f].pop(); } } } } } if(visited[n]){ cout<<num; return 0; } num++; } cout<<-1; return 0; }
a.cc:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 13 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:35:43: error: request for member 'first' in 'v[a].std::queue<std::pair<int, int> >::front().std::pair<int, int>::second', which is of non-class type 'int' 35 | int c=v[a].front().second.first; | ^~~~~
s588890129
p04003
C++
#include "bits/stdc++.h" #define ll long long #define rep2(i,a,b) for(int i=(a);i<=(b);++i) #define rep(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> #define ti3 tuple<int,int,int> int MOD=1000000000+7; int INF=1e6; using namespace std; string alphabet("abcdefghijklmnopqrstuvwxyz"); main(){ int n,m,visited[110000]={}; queue<pii> v[110000]; cin>>n>>m; rep(i,m){ int a,b,c; cin>>a>>b>>c; v[a].push({b,c}); v[b].push({a,c}); } int num=1; queue<int> now; now.push(1); visited[1]=1; while(!now.empty()){ int t=now.size(); rep(i,t){ int a=now.front(); now.pop(); int s=v[a].size(); rep(j,s){ int d=v[a].front().first; int c=v[a].front().second.first; v[a].pop(); visited[d]=1; now.push(d); queue<int> q; q.push(d); while(!q.empty()){ int f=q.front(); q.pop(); int h=v[f].size(); rep(ii,v[f].size()){ if(v[f].front().second==c){ if(!visited[v[f].front().first]) now.push(v[f].front().first); q.push(v[f].front().first); visited[v[f].front().first]=1; v[f].pop(); } else{ v[f].push(v[f].front()); v[f].pop(); } } } } } if(visited[n]){ cout<<num; return 0; } num++; } cout<<-1; return 0; }
a.cc:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 13 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:35:43: error: request for member 'first' in 'v[a].std::queue<std::pair<int, int> >::front().std::pair<int, int>::second', which is of non-class type 'int' 35 | int c=v[a].front().second.first; | ^~~~~
s867281715
p04003
C++
#include<bits/stdc++.h> #define INF 0x7fffffff #define ll long long #define P pair<int,int> #define MP(a,b) make_pair(a,b) using namespace std; P q[100005]; int n,m,dis[100005],head,tail,t,h[100005]; struct E{int v,c,next;}g[400005]; void ins(int u,int v,int c){g[++t].v=v,g[t].c=c,g[t].next=h[u],h[u]=t;} inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();} return x*f; } int main(){ memset(dis,0x3f,sizeof dis); dis[1]=0; n=read(),m=read(); for(int i=1;i<=m;++i){ int u,v,c; u=read(),v=read(),c=read(); ins(u,v,c); ins(v,u,c); } q[++tail]=MP(0,1); while(head<=tail){ int u=q[++head].second,lc=q[head].first; for(int j=h[u];j;j=g[j].next){ int v=g[j].v,c=g[j].c,d=dis[u]+((lc==c)?0:1); if(d>=dis[v]) continue; q[++tail]=MP(c,v); dis[v]=d; } } printf("%d",dis[n]==1061109567?-1:dis[]); }
a.cc: In function 'int main()': a.cc:35:47: error: expected primary-expression before ']' token 35 | printf("%d",dis[n]==1061109567?-1:dis[]); | ^
s138036328
p04003
C++
#include<bits/stdc++.h> #define MAXN 1000010 #define MAXM 1000010 #define INF 0x3f3f3f3f #define LL long long using namespace std; int read() { int res=0; char ch=getchar(); while(ch<'0' || ch>'9') ch=getchar(); while(ch>='0' && ch<='9') { res=res*10+ch-'0'; ch=getchar(); } return res; } struct Edge { int from,to,next,com; Edge(){} Edge(int u,int v,int n,int c):from(u),to(v),next(n),com(c){} }; struct Node { int d,u; bool operator < (const Node &rhs) const { return d>rhs.d; } }; int n,m,cnt; Edge edges[MAXM]; int head[MAXN],tot,vis[MAXN],dis[MAXN]; vector<int> comp[MAXN],G[MAXN]; void AddEdge(int u,int v,int com) { edges[tot]=Edge(u,v,head[u],com); head[u]=tot++; edges[tot]=Edge(v,u,head[v],com); head[v]=tot++; } set<int> dict; void init() { tot=0; for(int i=1;i<=n;++i) head[i]=-1; } void dijkstra(int s) { for(int i=1;i<=n+cnt) dis[i]=INF,vis[i]=0; priority_queue<Node> q; dis[s]=0; q.push((Node){0,s}); while(!q.empty()) { Node x=q.top(); q.pop(); int u=x.u; if(vis[u]) continue; vis[u]=1; int len=G[u].size(); for(int i=0;i!=len;++i) { int v=G[u][i]; if(dis[v]>dis[u]+1) { dis[v]=dis[u]+1; q.push((Node){dis[v],v}); } } } } int main() { n=read(),m=read(); init(); for(int i=0;i!=m;++i) { int u,v,com; u=read(),v=read(),com=read(); AddEdge(u,v,com); comp[com].push_back(u); comp[com].push_back(v); dict.insert(com); } for(set<int>::iterator it=dict.begin();it!=dict.end();++it) { int com=*it; int len=comp[com].size(); for(int i=0;i!=len;++i) { int u=comp[com][i]; if(vis[u]==com) continue; vis[u]=com; queue<int> q; q.push(u); ++cnt; while(!q.empty()) { int u=q.front(); q.pop(); for(int j=head[u];~j;j=edges[j].next) { Edge &e=edges[j]; if(e.com!=com) continue; if(vis[e.to]!=com) { vis[e.to]=com; q.push(e.to); } } G[u].push_back(n+cnt); G[n+cnt].push_back(u); } } } dijkstra(1); int ans; if(dis[n]==INF) ans=-1; else ans=dis[n]/2; printf("%d\n",ans); }
a.cc: In function 'void dijkstra(int)': a.cc:58:29: error: expected ';' before ')' token 58 | for(int i=1;i<=n+cnt) dis[i]=INF,vis[i]=0; | ^ | ;
s610330504
p04003
C++
https://docs.google.com/spreadsheets/d/1NMzLiCHgiEkSukTvFjiH0vxunr4-XT1XRAihKIleq3g/htmlview?sle=true#
a.cc:1:1: error: 'https' does not name a type 1 | https://docs.google.com/spreadsheets/d/1NMzLiCHgiEkSukTvFjiH0vxunr4-XT1XRAihKIleq3g/htmlview?sle=true# | ^~~~~
s254338939
p04003
C++
#include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<iostream> #include<cmath> #include<cstdlib> #include<queue> #include<vector> #define pa pair<int,int> using namespace std; const int MAXN=1000010; int dis[MAXN]; vector <pa> g[MAXN]; vector <int> new_g[MAXN],all[MAXN]; int visit[MAXN],ptr[MAXN]; queue <int> q; int main() { int n,m; scanf("%d%d",&n,&m); for (int i=1;i<=m;i++) { int u,v,c; scanf("%d%d%d",&u,&v,&c); u--,v--; g[u].push_back(make_pair(c,v)); g[v].push_back(make_pair(c,u)); all[c].push_back(u); all[c].push_back(v); } for (int i=0;i<n;i++) { sort(g[i].begin(),g[i].end()); visit[i]=-1; } int newn=n; for (int i=0;i<MAXN;i++) { if (all[i].empty()) { continue; } for (int it=0;it<all[i].size();it++) { int v=all[i][it]; if (visit[v]==i) { continue; } visit[v]=i; new_g[x].push_back(newn); new_g[newn].push_back(x); newn++; } } for (int i=0;i<newn;i++) { dis[i]=-2; } q.push(0); dis[0]=0; while (!q.empty()) { int x=q.front(); q.pop(); for (int i=0;i<new_g[x].size();i++) { int u=new_g[x][i]; if (dis[u]==-2) { dis[u]=dis[x]+1; q.push(u); } } } cout<<dis[n-1]/2; return 0; }
a.cc: In function 'int main()': a.cc:54:31: error: 'x' was not declared in this scope 54 | new_g[x].push_back(newn); | ^
s143750687
p04003
C++
#include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<iostream> #include<cmath> #include<cstdlib> #include<queue> #include<vector> #define pa pair<int,int> using namespace std; const int MAXN=1000010; int dis[MAXN]; vector <pa> g[MAXN]; vector <int> new_g[MAXN],all[MAXN]; int visit[MAXN],ptr[MAXN]; queue <int> q; int main() { int n,m; scanf("%d%d",&n,&m); for (int i=1;i<=m;i++) { int u,v,c; scanf("%d%d%d",&u,&v,&c); u--,v--; g[u].push_back(make_pair(c,v)); g[v].push_back(make_pair(c,u)); all[c].push_back(u); all[c].push_back(v); } for (int i=0;i<n;i++) { sort(g[i].begin(),g[i].end()); visit[i]=-1; } int newn=n; for (int i=0;i<MAXN;i++) { if (all[i].empty()) { continue; } for (int it=0;it<all[i].size();it++) { int v=all[i][it]; if (visit[v]==i) { continue; } visit[v]=i; new_g[x].push_back(newn); new_g[newn].push_back(x); newn++; } } for (int i=0;i<newn;i++) { dis[i]=-2; } q.push(0); dis[0]=0; while (!q.empty()) { int x=q.front(); q.pop(); for (int i=0;i<new_g[x].size();i++) { int u=new_g[x][i]; if (dis[u]==-2) { dis[u]=dis[x]+1; q.push(u); } } } cout<<dis[n-1]/2; return 0; }
a.cc: In function 'int main()': a.cc:54:31: error: 'x' was not declared in this scope 54 | new_g[x].push_back(newn); | ^
s774205093
p04003
C++
# include <bits/stdc++.h> # define x first # define y second # define mp make_pair // everything go according to my plan # define pb push_back # define sz(a) (int)(a.size()) # define vec vector // shimkenttin kyzdary, dzyn, dzyn, dzyn... # define y1 Y_U_NO_y1 # define left Y_U_NO_left # define right Y_U_NO_right using namespace std; typedef pair <int, int> pii; typedef long long ll; typedef long double ld; const int Mod = (int)1e9 + 7; const int MX = 1073741822; const ll MXLL = 4e18; const int Sz = 2110111; // a pinch of soul inline void Read_rap () { ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0); } inline void randomizer3000 () { unsigned int seed; asm ("rdtsc" : "=A"(seed)); srand (seed); } void files (string problem) { if (fopen ((problem + ".in").c_str(),"r")) { freopen ((problem + ".in").c_str(),"r",stdin); freopen ((problem + ".out").c_str(),"w",stdout); } } void localInput(const char in[] = "s") { if (fopen (in, "r")) { freopen (in, "r", stdin); } else cerr << "Warning: Input file not found" << endl; } const int N = 1e5 + 1; const int M = 2e5 + 1; int n, m; map <int, vec<int> > l[N]; vec<int> C[N]; int x[M], y[M], c[M]; struct graph { int n; vec<pii> g[6*M]; int d[6*M]; graph (int n) : n(n) {} void add_edge (int x, int y, int w) { cout << x << ' ' << y << ' ' << w << " :: "; g[x].pb ({y, w}); g[y].pb ({x, w}); } void add1_edge (int x, int y, int w) { if (x > 6*M-1) { cout << -1; return 0; } g[x].pb ({y, w}); } int bfs (vec<int> &st, vec<int> &f) { for (int i = 1; i <= n; i++) d[i] = n + 1; deque <int> q; for (int s : st) { q.push_front (s); d[s] = 1; } while (!q.empty()) { int v = q.front(); q.pop_front(); for (auto x : g[v]) { int to = x.x; int w = x.y; if (d[v] + w < d[to]) { d[to] = d[v] + w; if (w) q.push_back (to); else q.push_front (to); } } } int ans = n+1; for (auto t : f) ans = min (ans, d[t]); if (ans > n) return -1; else return ans; } }; int main() { # ifdef Local //localInput(); # endif Read_rap(); cin >> n >> m; for (int i = 1; i <= m; i++) { static int x, y, c; cin >> x >> y >> c; l[x][c].pb (i); l[y][c].pb (i); ::x[i] = x; ::y[i] = y; ::c[i] = c; } graph G (m); int &nodes = G.n; vec<int> pref[N], suff[N], t[N]; for (int i = 1; i <= n; i++) { pref[i].resize (sz(l[i])); suff[i].resize (sz(l[i])); int j = 0; for (auto x : l[i]) { C[i].pb (x.x); int c = ++nodes; t[i].pb (c); for (int y : x.y) G.add1_edge (c, y, 0); pref[i][j] = ++nodes; G.add1_edge (pref[i][j], c, 0); if (j) G.add1_edge (pref[i][j], pref[i][j - 1], 0); j++; } for (int k = sz(C[i]) - 1; k >= 0; k--) { int clr = C[i][k]; vec<int> &a = l[i][clr]; int c = t[i][k]; suff[i][k] = ++nodes; G.add1_edge (suff[i][k], c, 0); if (k + 1 < sz(C[i])) G.add1_edge (suff[i][k], suff[i][k + 1], 0); } } for (int i = 1; i <= ::m; i++) { int x = ::x[i]; int y = ::y[i]; int c = ::c[i]; int m; m = lower_bound (C[x].begin(), C[x].end(), c) - C[x].begin(); G.add1_edge (i, t[x][m], 0); if (m) G.add1_edge (i, pref[x][m - 1], 1); if (m + 1 < sz(C[x])) G.add1_edge (i, suff[x][m + 1], 1); m = lower_bound (C[y].begin(), C[y].end(), c) - C[y].begin(); G.add1_edge (i, t[y][m], 0); if (m) G.add1_edge (i, pref[y][m - 1], 1); if (m + 1 < sz(C[y])) G.add1_edge (i, suff[y][m + 1], 1); } vec<int> st, f; for (int i = 1; i <= m; i++) { if (x[i] == 1 || y[i] == 1) st.pb (i); if (x[i] == n || y[i] == n) f.pb (i); } assert (nodes <= 6*M-1); return 0; cout << G.bfs (st, f); return 0; } // Coded by Z..
a.cc: In member function 'void graph::add1_edge(int, int, int)': a.cc:72:14: error: return-statement with a value, in function returning 'void' [-fpermissive] 72 | return 0; | ^
s735358574
p04003
C++
# include <iostream> # include <algorithm> #include <array> # include <cassert> #include <cctype> #include <climits> #include <numeric> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <tuple> # include <utility> # include <stack> # include <queue> # include <list> # include <bitset> # include <complex> # include <chrono> # include <random> # include <limits.h> # include <unordered_map> # include <unordered_set> # include <deque> # include <cstdio> # include <cstring> #include <stdio.h> #include <stdlib.h> #include <cstdint> #include <cfenv> //#include <bits/stdc++.h> using namespace std; using LL = long long; using ULL = unsigned long long; long long MOD = 1000000000 + 7; constexpr long long INF = std::numeric_limits<long long>::max(); const double PI = acos(-1); #define fir first #define sec second #define thi third #define debug(x) cerr<<#x<<": "<<x<<'\n' typedef pair<LL, LL> Pll; typedef pair<LL, pair<LL, LL>> Ppll; typedef pair<LL, pair<LL, bitset<100001>>> Pbll; typedef pair<LL, pair<LL, vector<LL>>> Pvll; typedef pair<LL, LL> Vec2; struct Tll { LL first, second, third; }; typedef pair<LL, Tll> Ptll; #define rep(i,rept) for(LL i=0;i<rept;i++) #define Mfor(i,mf) for(LL i=mf-1;i>=0;i--) int h, w, n, m, k, s, t, q, last, cnt, sum, ans, d[400000]; string str, ss; bool f; char c; int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } }; struct Edge { int to, cost; }; vector<Edge>vec[200000]; void YN(bool f) { if (f) cout << "YES" << endl; else cout << "NO" << endl; } void yn(bool f) { if (f) cout << "Yes" << endl; else cout << "No" << endl; } void dijk(LL s) { for (LL i = 0; i < 400000; i++) d[i] = INF; d[s] = 0; priority_queue<Ppll, vector<Ppll>, greater<Ppll>> pq; pq.push(Ppll(d[s], Pll(s, -1))); // (cost,頂点番号) while (!pq.empty()) { Ppll pp; pp = pq.top(); LL cos = pp.first, vv = pp.second.fir, com = pp.sec.sec; pq.pop(); if (d[vv] < pp.first)continue; if (com == -1) { d[vv] = min(d[vv], cos + 1); cos = d[vv]; } for (int i = 0; i < vec[vv].size(); i++) { if (com == -1) { if (cos + 1 < d[vec[vv][i].to]) { pq.push(Ppll(cos, Pll(vec[vv][i].to, vec[vv][i].cost))); } } else { if (com == vec[vv][i].cost || vec[vv][i].cost == -1) { if (cos + 1 < d[vec[vv][i].to]) { pq.push(Ppll(cos, Pll(vec[vv][i].to, vec[vv][i].cost))); } } } } } } int main() { cin >> n >> m; rep(i, m) { LL x, y, z; cin >> x >> y >> z; x--, y--; vec[x].push_back(Edge{ y,z }); vec[y].push_back(Edge{ x,z }); } rep(i, n) vec[i].push_back(Edge{ i,-1 }); dijk(0); cout << (d[n - 1] == INF ? -1 : d[n - 1]) << endl; return 0; }
a.cc: In function 'void dijk(LL)': a.cc:75:24: warning: overflow in conversion from 'long long int' to 'int' changes value from '9223372036854775807' to '-1' [-Woverflow] 75 | d[i] = INF; | ^~~ a.cc:86:36: error: no matching function for call to 'min(int&, LL)' 86 | d[vv] = min(d[vv], cos + 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:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:86:36: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'LL' {aka 'long long int'}) 86 | d[vv] = min(d[vv], cos + 1); | ~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:86:36: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 86 | d[vv] = min(d[vv], cos + 1); | ~~~^~~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:112:40: warning: narrowing conversion of 'y' from 'LL' {aka 'long long int'} to 'int' [-Wnarrowing] 112 | vec[x].push_back(Edge{ y,z }); | ^ a.cc:112:42: warning: narrowing conversion of 'z' from 'LL' {aka 'long long int'} to 'int' [-Wnarrowing] 112 | vec[x].push_back(Edge{ y,z }); | ^ a.cc:113:40: warning: narrowing conversion of 'x' from 'LL' {aka 'long long int'} to 'int' [-Wnarrowing] 113 | vec[y].push_back(Edge{ x,z }); | ^ a.cc:113:42: warning: narrowing conversion of 'z' from 'LL' {aka 'long long int'} to 'int' [-Wnarrowing] 113 | vec[y].push_back(Edge{ x,z }); | ^ a.cc:116:40: warning: narrowing conversion of 'i' from 'LL' {aka 'long long int'} to 'int' [-Wnarrowing] 116 | vec[i].push_back(Edge{ i,-1 }); | ^
s970026550
p04003
C++
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashSet; import java.util.LinkedList; import java.util.Queue; import java.util.Set; import java.util.StringTokenizer; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; int M = 1000000; // int N = 10; void solve() throws IOException { int N = ni(); int m = ni(); Set<Integer>[] routes = new Set[M + 1]; for (int i = 0; i < routes.length; i++) routes[i] = new HashSet<Integer>(); Set<Integer>[] stops = new Set[N + 1]; for (int i = 0; i < stops.length; i++) stops[i] = new HashSet<Integer>(); for (int i = 0; i < m; i++) { int p = ni(); int q = ni(); int r = ni(); routes[r].add(p); routes[r].add(q); stops[q].add(r); stops[p].add(r); } boolean[] visited = new boolean[N + 1]; boolean[] visited2 = new boolean[M + 1]; Queue<Integer> q = new LinkedList<Integer>(); q.add(1); visited[1] = true; int ans = 1; while (!q.isEmpty()) { int size = q.size(); for (int i = 0; i < size; i++) { int j = q.poll(); for (int r : stops[j]) { if (!visited2[r]) { visited2[r] = true; for (int j2 : routes[r]) { if (j2 == N) { out.println(ans); return; } if (!visited[j2]){ q.add(j2); visited[j2] = true; } } } } } ans++; } out.println(-1); } String ns() throws IOException { while (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine(), " "); } return tok.nextToken(); } int ni() throws IOException { return Integer.parseInt(ns()); } long nl() throws IOException { return Long.parseLong(ns()); } double nd() throws IOException { return Double.parseDouble(ns()); } String[] nsa(int n) throws IOException { String[] res = new String[n]; for (int i = 0; i < n; i++) { res[i] = ns(); } return res; } int[] nia(int n) throws IOException { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = ni(); } return res; } long[] nla(int n) throws IOException { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nl(); } return res; } public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); tok = new StringTokenizer(""); Main main = new Main(); main.solve(); out.close(); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStreamReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.io.PrintWriter; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.util.HashSet; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.util.LinkedList; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: 'import' does not name a type 7 | import java.util.Queue; | ^~~~~~ a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:1: error: 'import' does not name a type 8 | import java.util.Set; | ^~~~~~ a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:1: error: 'import' does not name a type 9 | import java.util.StringTokenizer; | ^~~~~~ a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:11:1: error: expected unqualified-id before 'public' 11 | public class Main { | ^~~~~~
s648719161
p04003
C++
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashSet; import java.util.LinkedList; import java.util.Queue; import java.util.Set; import java.util.StringTokenizer; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; int M = 1000000; // int N = 10; @SuppressWarnings("unchecked") void solve() throws IOException { int N = ni(); int m = ni(); Set<Integer>[] routes = new Set[M + 1]; for (int i = 0; i < routes.length; i++) routes[i] = new HashSet<Integer>(); Set<Integer>[] stops = new Set[N + 1]; for (int i = 0; i < stops.length; i++) stops[i] = new HashSet<Integer>(); for (int i = 0; i < m; i++) { int p = ni(); int q = ni(); int r = ni(); routes[r].add(p); routes[r].add(q); stops[q].add(r); stops[p].add(r); } boolean[] visited = new boolean[N + 1]; boolean[] visited2 = new boolean[M + 1]; Queue<Integer> q = new LinkedList<Integer>(); q.add(1); visited[1] = true; int ans = 1; while (!q.isEmpty()) { int size = q.size(); for (int i = 0; i < size; i++) { int j = q.poll(); for (int r : stops[j]) { if (!visited2[r]) { visited2[r] = true; for (int j2 : routes[r]) { if (j2 == N) { out.println(ans); return; } if (!visited[j2]){ q.add(j2); visited[j2] = true; } } } } } ans++; } out.println(-1); } String ns() throws IOException { while (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine(), " "); } return tok.nextToken(); } int ni() throws IOException { return Integer.parseInt(ns()); } long nl() throws IOException { return Long.parseLong(ns()); } double nd() throws IOException { return Double.parseDouble(ns()); } String[] nsa(int n) throws IOException { String[] res = new String[n]; for (int i = 0; i < n; i++) { res[i] = ns(); } return res; } int[] nia(int n) throws IOException { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = ni(); } return res; } long[] nla(int n) throws IOException { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nl(); } return res; } public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); tok = new StringTokenizer(""); Main main = new Main(); main.solve(); out.close(); } }
a.cc:20:9: error: stray '@' in program 20 | @SuppressWarnings("unchecked") | ^ a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStreamReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.io.PrintWriter; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.util.HashSet; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.util.LinkedList; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: 'import' does not name a type 7 | import java.util.Queue; | ^~~~~~ a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:1: error: 'import' does not name a type 8 | import java.util.Set; | ^~~~~~ a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:1: error: 'import' does not name a type 9 | import java.util.StringTokenizer; | ^~~~~~ a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:11:1: error: expected unqualified-id before 'public' 11 | public class Main { | ^~~~~~
s953384033
p04003
C++
// see https://github.com/LumaKernel/vimfiles/tree/master/snippets/cp-cpp/temp.snip /// --- .lumrc Template {{{ /// // #define DEBUG // #define assert(...) #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using P = tuple<int, int>; using P3 = tuple<ll, ll, ll>; using VI = vector<int>; using VL = vector<ll>; using VVI = vector<VI>; using VVL = vector<VL>; using VP = vector<P>; using VS = vector<string>; #define omajinai ios::sync_with_stdio(false),cin.tie(0) #define FOR(i,a,b) for(int i=int(a);i<int(b);++i) #define FORI(i,a,b) for(int i=int(a);i<=int(b);++i) #define REP(i,n) FOR(i,0,n) #define REPI(i,n) FORI(i,0,n) #define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i) #define RFORI(i,a,b) for(int i=int(b);i>=int(a);--i) #define RREP(i,n) RFOR(i,0,n) #define RREPI(i,n) RFORI(i,0,n) #define ALL(a) begin(a),end(a) #define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end()) #define PB push_back #define EACH(i,c) REP(i,(c).size()) #define REACH(i,c) RREP(i,(c).size()) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort(ALL(c)) #define BR cout<<"\n"; #ifdef DEBUG #define dump(...) cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n"; #else #define dump(...) #endif #define YES(x) cout<<((x)?"YES":"NO")<<"\n"; #define Yes(x) cout<<((x)?"Yes":"No")<<"\n"; #define yes(x) cout<<((x)?"yes":"no")<<"\n"; int __int_temp; ll __ll_temp; string __string_temp; #define oini (omajinai, cin>>__int_temp, __int_temp) #define oinl (omajinai, cin>>__ll_temp, __ll_temp) #define oins (omajinai, cin>>__string_temp, __string_temp) #define ini (cin>>__int_temp, __int_temp) #define inl (cin>>__ll_temp, __ll_temp) #define ins (cin>>__string_temp, __string_temp) #define isInside(y,x) (0<=(y)&&(y)<h&&0<=(x)&&(x)<w) #define fi(x) (get<0>(x)) #define se(x) (get<1>(x)) #define th(x) (get<2>(x)) #define fo(x) (get<3>(x)) #define fif(x) (get<4>(x)) template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '{'; EACH(i, v) o << v[i] << (i != (int)v.size()-1 ? ", " : ""); o << "}"; return o; } template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){} template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); } template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; } template <typename T> inline void smax(T &a, T b) { a = a > b ? a : b; } template <typename T> inline void smin(T &a, T b) { a = a < b ? a : b; } template<typename T> inline int intlog2(T x); template<> inline int intlog2(int x) { return x == 0 ? 0 : 32 - __builtin_clz(x); } template<> inline int intlog2(ll x) { return x == 0 ? 0 : 64 - __builtin_clzll(x); } constexpr double PI = acos(-1); /// }}}--- /// constexpr int INF = 1e9+1; constexpr ll LINF = 1e18+1; constexpr int MOD = 1e9+7; const int N = 1e5; const int M = 2e5; using D = tuple<int, int, int>; map<int, int> dist[N]; int step[N]; VP g[N]; int main() { omajinai; int n,m; cin>>n>>m; REP(i, m) { int p, q, c; cin>>p>>q>>c; p--;q--; g[p].emplace_back(q, c); g[q].emplace_back(p, c); } // BFS queue<P> q; q.emplace(1, 0); step[0] = 1; step[n-1] = -1; while(q.size()) { int d = fi(q.front()), i = se(q.front()); q.pop(); for(auto e : g[i]) { int j = fi(e); if(step[j] <= 0) step[j] = d + 1, q.emplace(d + 1, j); } } if(step[n-1] == -1) { cout << -1 << endl; return 0; } // 01BFS deque<D> deq; deq.emplace_back(0, 0, -1); dist[0][-1] = 0; dist2[0] = 0; while(deq.size()) { D dat = deq.front(); deq.pop_front(); int d = fi(dat), i = se(dat), t = th(dat); if(i == n-1) { cout << d << endl; return 0; } if(d > dist[i][t]) continue; if(d > step[i]) continue; if(d > step[n-1]) continue; for(auto e : g[i]) { int j = fi(e), c = se(e); if(t != -1) { if(t == c) { if(!dist[j].count(c) || d < dist[j][c]) { dist[j][c] = d; smin(dist2[j], d); deq.emplace_front(d, j, c); } } } else { if(!dist[i].count(c) || d+1 < dist[i][c]) { dist[i][c] = d+1; deq.emplace_back(d+1, i, c); } } } if(t != -1) if(!dist[i].count(-1) || d < dist[i][-1]) { dist[i][-1] = d; deq.emplace_front(d, i, -1); } } cout << -1 << endl; }
a.cc: In function 'int main()': a.cc:129:3: error: 'dist2' was not declared in this scope; did you mean 'dist'? 129 | dist2[0] = 0; | ^~~~~ | dist
s429049707
p04003
C++
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <array> #include <vector> #include <utility> #include <bitset> #include <queue> #include <unordered_map> #include <unordered_set> using namespace std; typedef long long ll; typedef pair<ll, ll> p; constexpr ll INF = 1e18; struct node { ll n; ll c; node (ll n, ll c) : n(n), c(c) {} }; /* struct route { node to; ll cost; route(node to, ll cost) : to(to), cost(cost) {} }; */ ll N, M; // vectorだとかぶりが発生してダメなはず vector<unordered_map<ll, unordered_map<ll, unordered_set<ll> > > > G; vector<unordered_map<ll, ll> > dist; queue<p> que; int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; G = vector<unordered_map<ll, unordered_map<ll, unordered_set<ll> > > >(N + 1); dist = vector<unordered_map<ll, ll> >(N + 1); for (ll i = 0; i < M; i++) { ll p, q, c; cin >> p >> q >> c; // move in same campanies G[p][c][q].insert(c); G[q][c][p].insert(c); // exit and enter G[p][c][p].insert(0); G[p][0][p].insert(c); G[q][c][q].insert(0); G[q][0][q].insert(c); dist[p][0] = INF; dist[q][0] = INF; dist[p][c] = INF; dist[q][c] = INF; } que.push(make_pair(1, 0)); dist[1][0] = 0; while (!que.empty()) { auto token = que.front(); que.pop(); for (auto Q : G[token.first][token.second]) { auto q = Q.first; for (auto c : Q.second) { ll newcost = dist[token.first][token.second]; if (token.second == 0) { newcost++; } if (newcost < dist[q][c]) { dist[q][c] = newcost; que.push(make_pair(q, c)); } } } } cout << (dist[N][0] == INF ? "-1" : dist[N][0]) << endl; return 0; }
a.cc: In function 'int main()': a.cc:92:32: error: operands to '?:' have different types 'const char*' and 'std::unordered_map<long long int, long long int>::mapped_type' {aka 'long long int'} 92 | cout << (dist[N][0] == INF ? "-1" : dist[N][0]) << endl;
s937766338
p04003
C++
/* cat <<EOF >mistaken-paste */ #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <math.h> #define BIG 2000000007 #define VERYBIG 200000000000007LL #define MOD 1000000007 typedef uint64_t ull; typedef int64_t sll; #define N_MAX 300000 #define M_MAX 200000 #ifdef __cplusplus #include <queue> #include <stack> // #include <tuple> #include <set> // using namespace std; // HELL using std::queue; using std::priority_queue; using std::stack; // using std::tuple; using std::set; using std::vector; using std::greater; using std::pair; typedef priority_queue<ull, vector<ull>, greater<ull> > upque123; typedef priority_queue<ull, vector<ull> > upque321; typedef priority_queue<sll, vector<sll>, greater<sll> > spque123; typedef priority_queue<sll, vector<sll> > spque321; #endif typedef struct { int32_t a; int32_t b; } hw; typedef struct { sll a; sll b; } hwll; typedef struct { hwll a; hwll b; } linell; typedef struct { ull s; ull t; int32_t c; } struct_a; typedef struct { int32_t from; int32_t to; sll cost; } struct_b; const hw vector8[8] = { {-1, -1}, {-1, 0}, {-1, +1}, { 0, -1}, { 0, +1}, {+1, -1}, {+1, 0}, {+1, +1} }; ull n, m; ull h, w; ull k; ull q; ull vua, vub, vuc, vud, vue, vuf; sll vsa, vsb, vsc, vsd, vse, vsf; long double vra, vrb, vrc; double vda, vdb, vdc; size_t slen; size_t tlen; char ch, dh; void swap_adj (ull *a, ull *b) { if (*a != *b) { ull tmp = *b; *b = *a; *a = tmp; } return; } int32_t digits (ull x) { int32_t i = 1; while (x >= 10) { x /= 10; i++; } return i; } ull umin (ull x, ull y) { return (x < y) ? x : y; } ull umax (ull x, ull y) { return (x > y) ? x : y; } sll smin (sll x, sll y) { return (x < y) ? x : y; } sll smax (sll x, sll y) { return (x > y) ? x : y; } ull gcd (ull x, ull y) { if (x < y) { return gcd(y, x); } else if (y == 0) { return x; } else { return gcd(y, x % y); } } ull bitpow (ull a, ull x, ull modulo) { ull result = 1; while (x) { if (x & 1) { result *= a; result %= modulo; } x /= 2; a = (a * a) % modulo; } return result; } ull divide (ull a, ull b, ull modulo) { return (a * bitpow(b, modulo - 2, modulo)) % modulo; } ull ullabs (ull a, ull b) { if (a >= b) { return a - b; } else { return b - a; } } sll sllabs (sll a, sll b) { if (a >= b) { return a - b; } else { return b - a; } } sll nibutanlobo (bool (*func)(sll arg), sll ok, sll ng) { while (sllabs(ok, ng) > 1) { sll med = (ok + ng) / 2; if (func(med)) { ok = med; } else { ng = med; } // printf("debug: [%lld %lld)\n", ok, ng); } if (!func(ok)) return ok * 2 - ng; return ok; } void printUquotient (ull left, ull right) { const int32_t digits = 20; printf("%llu.", left / right); left %= right; for (int32_t i = 0; i < digits; i++) { left *= 10; printf("%1d", left / right); left %= right; } puts(""); return; } void printSquotient (sll left, sll right) { if (left * right < 0) putchar('-'); printUquotient(sllabs(left, 0), sllabs(right, 0)); return; } int bitcount (ull n) { int result = 0; while (n) { if (n & 1) result++; n /= 2; } return result; } // #ifdef __cplusplus // typedef struct { // int32_t to; // sll cost; // } edge; // typedef pair<sll, int32_t> P; // std::vector<edge> g[N_MAX]; // void dijk_init (ull n, struct_b arr[]) { // edge x; // for (int32_t i = 0; i < n; i++) { // x.to = arr[i].to; // x.cost = arr[i].cost; // g[arr[i].from].push_back(x); // } // } // bool dijkstra (int s, sll distance[]) { // priority_queue<P, std::vector<P>, greater<P> > que; // (最短距離, 頂点番号) // que.push(P(distance[s], s)); // bool ischanged = false; // while (!que.empty()) { // P p = que.top(); // que.pop(); // sll v = p.second; // if (distance[v] < p.first) continue; // int32_t maxsize = g[v].size(); // for (int32_t i = 0; i < maxsize; i++) { // edge e = g[v][i]; // if (distance[e.to] > distance[v] + e.cost) { // distance[e.to] = distance[v] + e.cost; // ischanged = true; // que.push(P(distance[e.to], e.to)); // } // } // } // return ischanged; // } // #endif sll dist[N_MAX]; struct_b path[M_MAX * 2]; // ull a[N_MAX]; // ull a[M_MAX]; // sll a[N_MAX]; // ull a[N_MAX][N_MAX]; // ull a[M_MAX][M_MAX]; // sll a[N_MAX][N_MAX]; // ull b[N_MAX]; // ull b[M_MAX]; // sll b[N_MAX]; // ull c[N_MAX]; sll c[M_MAX]; // char c[N_MAX]; // char s[N_MAX + 1]; // char s[N_MAX + 1][N_MAX + 1]; // char s[N_MAX + 1][M_MAX + 1]; // char t[N_MAX + 1]; // ull alphabets[26]; // ull blphabets[26]; // char alphabets[26]; // ull dp[N_MAX + 1]; // sll dp[N_MAX + 1]; // ull dp[N_MAX + 1][N_MAX + 1]; // sll dp[N_MAX + 1][N_MAX + 1]; // bool dp[N_MAX + 1]; // bool dp[N_MAX + 1][N_MAX + 1]; // hwll arr[N_MAX]; hwll arr[M_MAX]; // hwll brr[M_MAX]; double distance (sll x1, sll y1, sll x2, sll y2) { double xdist2, ydist2, origindist, dist; xdist2 = (x1 - x2) * (x1 - x2); ydist2 = (y1 - y2) * (y1 - y2); return sqrt(xdist2 + ydist2); } int32_t pullcomp (const void *left, const void *right) { ull l = *(ull*)left; ull r = *(ull*)right; if (l < r) { return -1; } if (l > r) { return +1; } return 0; } int32_t phwllABcomp (const void *left, const void *right) { hwll l = *(hwll*)left; hwll r = *(hwll*)right; if (l.a < r.a) { return -1; } if (l.a > r.a) { return +1; } if (l.b < r.b) { return -1; } if (l.b > r.b) { return +1; } return 0; } typedef pair<sll, sll> statedata; typedef pair<sll, statedata> dijkquecell; vector<statedata> g[N_MAX]; set<sll> cameway[N_MAX]; // set<sll> seenway[N_MAX]; priority_queue<dijkquecell, vector<dijkquecell>, greater<dijkquecell> > que; ull solve () { sll i, j, ki; // ull result = 0; sll result = 0; // double result = 0; ull maybe = 0; // sll maybe = 0; ull sum = 0; // sll sum = 0; ull item; ull *dpcell; clock_t start = clock(); for (i = 0; i < m; i++) { g[arr[i].a].push_back(statedata(arr[i].b, c[i])); g[arr[i].b].push_back(statedata(arr[i].a, c[i])); } for (i = 0; i < n; i++) { dist[i] = BIG; } dist[0] = 0; que.push(dijkquecell(0, statedata(0, 0))); while (!que.empty()) { // fflush(stdout); // scanf("%*s"); dijkquecell p = que.top(); que.pop(); sll currv = p.second.first; sll currway = p.second.second; if (p.first > dist[currv]) continue; // if (p.first == dist[currv] && seenway[currv].find(currway) != seenway[currv].end()) continue; // seenway[currv].insert(currway); for (statedata x : g[currv]) { sll nextv = x.first; sll nextway = x.second; sll nextcost; // sll nextcost = p.first + ((currway == nextway) ? 0 : 1); // if (nextcost > dist[nextv]) continue; // if (nextcost < dist[nextv]) { // dist[nextv] = nextcost; // cameway[nextv].clear(); // cameway[nextv].insert(nextway); // seenway[nextv].clear(); // } else { // if (cameway[nextv].find(nextway) == cameway[nextv].end()) { // cameway[nextv].insert(nextway); // } else { // continue; // } // } if (currway == 0) { nextcost = p.first + 1; } else { nextcost = p.first; if (currway != nextway) { nextv = currv; nextway = 0; } } if (nextcost > dist[nextv]) continue; if (nextcost < dist[nextv]) { dist[nextv] = nextcost; cameway[nextv].clear(); cameway[nextv].insert(nextway); } else { if (cameway[nextv].find(nextway) == cameway[nextv].end()) { cameway[nextv].insert(nextway); } else { continue; } } dijkquecell nextcell = dijkquecell(nextcost, statedata(nextv, nextway)); // printf("%3lld(cost: %3lld, way: %3lld)->%3lld(cost: %3lld, way: %3lld)\n", currv, p.first, currway, nextv, nextcost, nextway); que.push(nextcell); } if (clock() - start >= 3 * CLOCKS_PER_SEC - 100) { if (n < 150000) { 1 / 0; } } } result = dist[n - 1]; if (result == BIG) goto fail; printf("%llu\n", result); // printf("%.12lf\n", (double)result); // puts(s); return 0; success: // puts("YES"); // puts("Yes"); // printf("%llu\n", result); // puts("0"); puts("Possible"); return 0; fail: // puts("NO"); // puts("No"); // puts("0"); puts("-1"); // puts("-1 -1 -1"); // puts("Impossible"); return 1; } int32_t main (void) { int32_t i, j; int32_t x, y; // scanf("%lf%lf", &vda, &vdb); // scanf("%lld%lld%lld%lld", &vsa, &vsb, &vsc, &vsd); // scanf("%llu%llu", &vua, &vub, &vuc, &vud); // scanf("%llu%llu", &h, &w); scanf("%llu%llu", &n, &m); // scanf("%*llu"); // scanf("%llu", &k, &m, &n); // scanf("%llu%llu", &vua, &vub, &vuc, &vud, &vue, &vuf); // scanf("%lld%lld", &vsa, &vsb, &vsc); // scanf("%s", s); // scanf("%s", t); // scanf("%llu", &m); // scanf("%llu", &q); // for (i = 0; i < n; i++) { // scanf("%llu", &a[i]); // // a[i]--; // } // for (i = 0; i < m; i++) { // scanf("%llu", &b[i]); // } // for (i = 0; i < h; i++) { // scanf("%llu", &a[i]); // } // for (i = 0; i < h; i++) { // for (j = 0; j < w; j++) { // scanf("%llu", &a[i][j]); // } // } // for (i = 0; i < w; i++) { // scanf("%llu", &b[i]); // } // for (i = 0; i < m; i++) { // scanf("%llu", &b[i]); // } // for (i = 0; i < h; i++) { // scanf("%s", s[i]); // } // scanf("%s", t); for (i = 0; i < m; i++) { // scanf("%llu", &a[i]); // scanf("%llu", &b[i]); scanf("%llu", &arr[i].a); scanf("%llu", &arr[i].b); scanf("%llu", &c[i]); arr[i].a--; arr[i].b--; // a[i]--; // b[i]--; } // for (i = 0; i < k; i++) { // scanf("%llu", &c[i]); // c[i]--; // } // for (i = 0; i < m; i++) { // scanf("%llu%llu", &arr[i].a, &arr[i].b); // arr[i].a--; // arr[i].b--; // } // for (i = 0; i < k; i++) { // scanf("%llu%llu", &brr[i].a, &brr[i].b); // brr[i].a--; // brr[i].b--; // } // for (i = 0; i < m; i++) { // for (j = 0; j < m; j++) { // scanf("%llu", &a[i][j]); // } // } // for (i = 0; i < n; i++) { // scanf("%llu%llu%llu", &a[i], &b[i], &c[i]); // } // scanf("%llu", &q); // scanf("%llu", &k); // k--; // for (i = 0; i < q; i++) { // scanf("%llu%llu%llu", &c[i], &a[i], &b[i]); // // a[i]--; // // b[i]--; // // solve(); // } // for (i = 0; i < m; i++) { // scanf("%llu%llu", &arr[i].a, &arr[i].b); // arr[i].a--; // arr[i].b--; // } // for (i = 0; i < n; i++) { // for (j = 0; j < m; j++) { // scanf("%llu", &a[i][j]); // a[i][j]--; // } // } solve(); // for (i = 0; i < m; i++) { // scanf("%llu%llu%llu", &vua, &vub, &vuc); // // scanf("%s%s", s, t); // // scanf("%f%f%f", &vda, &vdb, &vdc); // // scanf("%s", s); // solve(); // } // while (scanf("%llu%llu", &n, &k), n + k) { // for (i = 0; i < n; i++) { // scanf("%llu", &a[i]); // } // solve(); // } return 0; }
a.cc:5:32: warning: option '-Wincompatible-pointer-types' is valid for C/ObjC but not for C++ [-Wpragmas] 5 | #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc: In function 'ull solve()': a.cc:363:25: error: 'clock' was not declared in this scope 363 | clock_t start = clock(); | ^~~~~ a.cc:29:1: note: 'clock' is defined in header '<ctime>'; this is probably fixable by adding '#include <ctime>' 28 | #include <set> +++ |+#include <ctime> 29 | a.cc:440:44: error: 'CLOCKS_PER_SEC' was not declared in this scope 440 | if (clock() - start >= 3 * CLOCKS_PER_SEC - 100) { | ^~~~~~~~~~~~~~ a.cc:442:35: warning: division by zero [-Wdiv-by-zero] 442 | 1 / 0; | ~~^~~
s189601693
p04003
C++
#include <bits/stdc++.h> #define LL long long #define VI vector<int> #define VB vector<bool> #define VL vector<long long> #define FOR(i,a,b) for(int i= (a); i<((int)b); ++i) #define RFOR(i,a) for(int i=(a); i >= 0; --i) #define FOE(i,a) for(auto i : a) #define ALL(c) (c).begin(), (c).end() #define RALL(c) (c).rbegin(), (c).rend() #define DUMP(x) cerr << #x << " = " << (x) << endl; #define SUM(x) std::accumulate(ALL(x), 0LL) #define MIN(v) *std::min_element(v.begin(), v.end()) #define MAX(v) *std::max_element(v.begin(), v.end()) #define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end()) #define BIT(n) (1LL<<(n)) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); #define EPS 1e-14 const std::string YES = "YES"; const std::string Yes = "Yes"; const std::string NO = "NO"; const std::string No = "No"; using namespace std; /** * startからすべての頂点への最小距離を求める O(|E| log |V|) * @param start * @param graph[node] = [(to1, cost1), (to2, cost2), ...] * @return */ vector<int> dijkstra(int start, vector<vector<int>> graph) { unsigned long n = graph.size(); priority_queue<pair<int, int>> que; //[(最短距離, node番号)] que.push({0, start}); vector<int> prev_list(n, -1); vector<int> dist_list(n, INT_MAX); dist_list[start] = 0; while (!que.empty()) { int now_dist = que.top().first; int from = que.top().second; que.pop(); if (dist_list[from] < now_dist) { continue; } for (int to : graph[from]) { int dist = 1; int new_dist = now_dist + dist; if (dist_list[to] > new_dist) { prev_list[to] = from; dist_list[to] = new_dist; que.push({new_dist, to}); } } } return dist_list; } void dfs(pair<int, int> &start, vector<int> &route, vector<vector<bool>> &used, unordered_map<pair<int, int>, vector<pair<int, int>>> &graph) { FOE(p, graph[start]) { if (used[p.first][p.second]) { continue; } used[p.first][p.second] = true; route.emplace_back(p.first); dfs(p, route, used, graph); } } int solve(int N, int M, const vector<int> &P, vector<int> &Q, vector<int> &C) { unordered_map<pair<int, int>, vector<pair<int, int>>> graph; // (駅, 会社)から到達できる(駅, 会社)のリスト FOR(i, 0, P.size()) { graph[make_pair(P[i], C[i])].emplace_back(make_pair(Q[i], C[i])); graph[make_pair(Q[i], C[i])].emplace_back(make_pair(P[i], C[i])); } vector<vector<bool>> used(N + 1, vector<bool>(N + 1, false)); vector<vector<int>> station_route_graph(N * 3); int route_id = N + 2; FOE(&p, graph) { auto a = p.first; if (used[a.first][a.second]) { continue; } vector<int> route = {a.first}; used[a.first][a.second] = true; dfs(a, route, used, graph); FOE(station, route) { station_route_graph[station].push_back(route_id); station_route_graph[route_id].push_back(station); } route_id++; } auto dist_list = dijkstra(1, station_route_graph); int ans = dist_list[N]; return ans == INT_MAX ? -1 : ans / 2; } int main() { int N, M; cin >> N >> M; vector<int> P(M), Q(M), C(M); FOR(i, 0, M) { cin >> P[i] >> Q[i] >> C[i]; } cout << solve(N, M, P, Q, C) << endl; return 0; }
a.cc: In function 'int solve(int, int, const std::vector<int>&, std::vector<int>&, std::vector<int>&)': a.cc:79:59: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > > >]' 79 | unordered_map<pair<int, int>, vector<pair<int, int>>> graph; // (駅, 会社)から到達できる(駅, 会社)のリスト | ^~~~~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > > >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h: At global scope: /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, std::vector<std::pair<int, int>, std
s515322738
p04003
C++
#include <iostream> #include <vector> #include <map> #include <queue> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector<vector<pair<int, int>>> G(N); map<pair<int, int>, bool> vis; for(int i=0; i<M; i++){ int p, q, c; cin >> p >> q >> c; p--; q--; G[p].push_back(make_pair(q, c)); G[q].push_back(make_pair(p, c)); } priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> wsc; wsc.push(make_tuple(0, 0, 0)); vector<int> d(N, 1<<30); while(!wsc.empty()){ int w, s, c; tie(w, s, c) = wsc.top(); wsc.pop(); d[s] = min(d[s], w); for(auto sc : G[s]){ int tt = sc.first; int cc = sc.second; if(vis[make_pair(tt, cc)]) continue; vis[make_pair(tt, cc)] = true; if(c == cc) wsc.push(make_tuple(w, tt, cc)); else wsc.push(make_tuple(w+1, tt, cc)); } } if(d[N-1] == 1<<30) cout << -1 << endl; else cout << d[N-1] << endl; cerr << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:43:13: error: 'cnt' was not declared in this scope; did you mean 'int'? 43 | cerr << cnt << endl; | ^~~ | int
s477785531
p04003
C++
#include <iostream> #include <vector> #include <map> #include <queue> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector<vector<pair<int, int>>> G(N); map<pair<int, int>, bool> vis; for(int i=0; i<M; i++){ int p, q, c; cin >> p >> q >> c; p--; q--; G[p].push_back(make_pair(q, c)); G[q].push_back(make_pair(p, c)); } priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> wsc; for(auto sc : G[0]) wsc.push(make_tuple(1, sc.first, sc.second)); vector<int> d(N, 1<<30); d[0] = 0; while(!wsc.empty()){ int w, s, c; tie(w, s, c) = wsc.top(); wsc.pop(); d[s] = min(d[s], w); for(auto sc : G[s]){ int tt = sc.first; int cc = sc.second; if(vis[make_pair(tt, cc)]) continue; vis[make_tuple(tt, cc)] = true; if(c == cc) wsc.push(make_tuple(w, tt, cc)); else wsc.push(make_tuple(w+1, tt, cc)); } } if(d[N-1] == 1<<30) cout << -1 << endl; else cout << d[N-1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:37:16: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, bool>' and 'std::tuple<int, int>') 37 | vis[make_tuple(tt, cc)] = true; | ^ In file included from /usr/include/c++/14/map:63, from a.cc:3: /usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >; mapped_type = bool; key_type = std::pair<int, int>]' 504 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::tuple<int, int>' to 'const std::map<std::pair<int, int>, bool>::key_type&' {aka 'const std::pair<int, int>&'} 504 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >; mapped_type = bool; key_type = std::pair<int, int>]' 524 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::tuple<int, int>' to 'std::map<std::pair<int, int>, bool>::key_type&&' {aka 'std::pair<int, int>&&'} 524 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~
s012488798
p04003
C++
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <cmath> #include <queue> #include <map> #include <unordered_map> #include <set> #include <bitset> #include <functional> using namespace std; typedef long long ll; vector<pair<int, int>> edg[100003]; set<int> used[100003]; priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> que; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { int p, q, c; cin >> p >> q >> c; --p; --q; edg[p].push_back({ q, c }); edg[q].push_back({ p, c }); } que.push({ 0, {0, -1} }); while (!que.empty()) { int d = que.top().first; pair<int, int> pos = que.top().second; que.pop(); if (pos.first == n - 1) { cout << d << endl; return 0; } int t = pos.first, c = pos.second;  if (used[t].count(c) == 1) continue; used[t].insert(c); if (c == -1) { for (int i = 0; i < (int)edg[t].size(); ++i) { if (used[edg[t][i].first].count(edg[t][i].second) == 1) continue; que.push({ d + 1, edg[t][i] }); } } else { for (int i = 0; i < (int)edg[t].size(); ++i) { if (c != edg[t][i].second) { if (used[t].count(-1) == 1) continue; que.push({ d,{t, -1} }); } else { if (used[edg[t][i].first].count(edg[t][i].second) == 1) continue; que.push({ d, edg[t][i] }); } } } } cout << -1 << endl; return 0; }
a.cc:39:7: error: extended character   is not valid in an identifier 39 |  if (used[t].count(c) == 1) continue; | ^ a.cc: In function 'int main()': a.cc:39:7: error: '\U00003000if' was not declared in this scope 39 |  if (used[t].count(c) == 1) continue; | ^~~~
s346689188
p04003
C++
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <cmath> #include <queue> #include <map> #include <unordered_map> #include <set> #include <bitset> #include <functional> using namespace std; typedef long long ll; vector<pair<int, int>> edg[100003]; unordered_map<pair<int, int>, bool> used; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { int p, q, c; cin >> p >> q >> c; --p; --q; edg[p].push_back({ q, c }); edg[q].push_back({ p, c }); } priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> que; que.push({ 0, {0, -1} }); while (!que.empty()) { int d = que.top().first; pair<int, int> pos = que.top().second; que.pop(); if (pos.first == n - 1) { cout << d << endl; return 0; } if (used.find(pos) != used.end()) continue; used[pos] = true; int t = pos.first, c = pos.second; if (c == -1) { for (int i = 0; i < (int)edg[t].size(); ++i) { if (used.find(edg[t][i]) != used.end()) continue; que.push({ d + 1, edg[t][i] }); } } else { for (int i = 0; i < (int)edg[t].size(); ++i) { if (c != edg[t][i].second) { if (used.find({t,-1}) != used.end()) continue; que.push({ d,{t, -1} }); } else { if (used.find(edg[t][i]) != used.end()) continue; que.push({ d, edg[t][i] }); } } } } cout << -1 << endl; return 0; }
a.cc:18:37: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = bool; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >]' 18 | unordered_map<pair<int, int>, bool> used; | ^~~~ In file included from /usr/include/c++/14/unordered_map:41, from a.cc:8: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = bool; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, bool>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, bool>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, bool>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, bool>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, bool>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, 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/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, bool>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted functio
s468684919
p04003
C++
# include <iostream> # include <algorithm> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <tuple> # include <utility> # include <stack> # include <queue> # include <list> # include <bitset> # include <complex> # include <chrono> # include <random> # include <limits.h> # include <unordered_map> # include <unordered_set> # include <deque> # include <cstdio> # include <cstring> using namespace std; using LL = long long; using ULL = unsigned long long; constexpr long long MOD = 1000000000 + 7; constexpr long long INF = 1e17 - 10; const double PI = acos(-1); typedef pair<LL, LL> Pll; typedef pair<LL, pair<LL,LL>> Ppll; typedef pair<LL, LL> Vec2; typedef tuple<LL, LL, LL> Tll; typedef pair<LL, Tll> Ptll; #define rep(i,rept) for(LL i=0;i<rept;i++) #define Mfor(i,n) for(LL i=n-1;i>=0;i--) struct Edge { LL to,cost; }; vector<Edge>vec[1100000]; bitset<100002>bi[1000002]; LL h, w, n, m, s, t, sum, ans = 0, d[100002]; void DIUX(LL s) { for (int i = 0; i < 100002; i++) d[i] = INF; d[s] = 0; priority_queue<Ppll, vector<Ppll>, greater<Ppll>> pq; pq.push(make_pair(d[s], Pll(s, 0))); // (cost,頂点番号) while (!pq.empty()) { Ppll pp; pp = pq.top(); LL cos = pp.first, vv = pp.second.first, nn = pp.second.second; pq.pop(); if (d[vv] < pp.first)continue; rep(i, vec[vv].size()) if ((nn != vec[vv][i].cost ? 1 : 0) + d[vv] < d[vec[vv][i].to]) { d[vec[vv][i].to] = (nn != vec[vv][i].cost ? 1 : 0) + d[vv]; bi[vv][nn] = 1; pq.push(make_pair(d[vec[vv][i].to], Pll(vec[vv][i].to, vec[vv][i].cost))); } else if((nn != vec[vv][i].cost ? 1 : 0) + d[vv]==d[vec[vv][i].to]&&bi[vv][nn]==0) { d[vec[vv][i].to] = (nn != vec[vv][i].cost ? 1 : 0) + d[vv]; bi[vv][nn] = 1; pq.push(make_pair(d[vec[vv][i].to], Pll(vec[vv][i].to, vec[vv][i].cost))); } } } int main() { cin >> n >> m; rep(i, m) { cin >> s >> t >> w; vec[s].push_back(Edge{ t,w }); vec[t].push_back(Edge{ s,w }); } DIUX(1); cout << (d[n]==INF?-1:d[n]) << endl; return 0; }
/tmp/ccPdKQTx.o: in function `DIUX(long long)': a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccPdKQTx.o a.cc:(.text+0x5f): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccPdKQTx.o a.cc:(.text+0xb6): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccPdKQTx.o a.cc:(.text+0x16b): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccPdKQTx.o a.cc:(.text+0x1df): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccPdKQTx.o a.cc:(.text+0x223): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccPdKQTx.o a.cc:(.text+0x288): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccPdKQTx.o a.cc:(.text+0x2cc): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccPdKQTx.o a.cc:(.text+0x3cb): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccPdKQTx.o a.cc:(.text+0x45f): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccPdKQTx.o a.cc:(.text+0x4a3): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s420347117
p04003
Java
import java.io.*; import java.util.*; import java.math.*; // import java.awt.Point; public class Main { InputStream is; PrintWriter out; String INPUT = ""; long MOD = 1_000_000_007; int inf = Integer.MAX_VALUE; void solve(){ int n = ni(); int m = ni(); Dijkstra dijkstra = new Dijkstra((2*m+n+10); TreeMap<Long, Integer> reindex= new TreeMap<>(); long res = 0; for(int i = 0; i < m; i++){ long p = nl(); long q = nl(); long c = nl(); long from = (p<<32)+c; long to = (q<<32)+c; long fromout = (p<<32)-1; long toout = (q<<32)-1; if(!reindex.containsKey(fromout))reindex.put(fromout, reindex.size()); if(!reindex.containsKey(toout)) reindex.put(toout, reindex.size()); if(!reindex.containsKey(from)){ reindex.put(from, reindex.size()); dijkstra.addDirectedEdge(reindex.get(from), reindex.get(fromout), 0); dijkstra.addDirectedEdge(reindex.get(fromout), reindex.get(from), 1); res+=2; } if(!reindex.containsKey(to)){ reindex.put(to, reindex.size()); dijkstra.addDirectedEdge(reindex.get(to), reindex.get(toout), 0); dijkstra.addDirectedEdge(reindex.get(toout), reindex.get(to), 1); res+=2; } dijkstra.addDirectedEdge(reindex.get(from), reindex.get(to), 0); dijkstra.addDirectedEdge(reindex.get(to), reindex.get(from), 0); res+=2; } // out.println(reindex.size()); // out.println(res); long start = (1l<<32) - 1; long goal = ((long)n<<32) - 1; if(!reindex.containsKey(start) || !reindex.containsKey(goal)){ out.println(-1); return; } long[] dist = dijkstra.getDist(reindex.get(start)); long ans = dist[reindex.get(goal)]; if(ans == Long.MAX_VALUE / 3){ out.println(-1); return; } out.println(ans); } static class Dijkstra { int n; ArrayList<Pair>[] G; long INF = Long.MAX_VALUE / 3; public Dijkstra(int n) { this.n = n; G = new ArrayList[n]; for (int i = 0; i < n; i++) { G[i] = new ArrayList<>(); } } public void addDirectedEdge(int from, int to, int cost) { G[from].add(new Pair(to, cost)); } public long[] getDist(int s) { PriorityQueue<Pair> Q = new PriorityQueue<>(); Q.add(new Pair(s, 0)); long[] dist = new long[n]; Arrays.fill(dist, INF); boolean[] used = new boolean[n]; while (!Q.isEmpty()) { Pair p = Q.poll(); if (used[p.x]) continue; used[p.x] = true; dist[p.x] = p.y; for (Pair edge : G[p.x]) { Q.add(new Pair(edge.x, p.y + edge.y)); } } return dist; } class Pair implements Comparable<Pair> { int x; long y; Pair(int x, long y) { this.x = x; this.y = y; } public int compareTo(Pair p) { return Long.compare(y, p.y); } } } void run() throws Exception { is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms"); } public static void main(String[] args) throws Exception { new Main().run(); } private byte[] inbuf = new byte[1024]; private int lenbuf = 0, ptrbuf = 0; private int readByte() { if(lenbuf == -1)throw new InputMismatchException(); if(ptrbuf >= lenbuf){ ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf <= 0)return -1; } return inbuf[ptrbuf++]; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; } private double nd() { return Double.parseDouble(ns()); } private char nc() { return (char)skip(); } private String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while(!(isSpaceChar(b) && b != ' ')){ sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while(p < n && !(isSpaceChar(b))){ buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private char[][] nm(int n, int m) { char[][] map = new char[n][]; for(int i = 0;i < n;i++)map[i] = ns(m); return map; } private int[] na(int n) { int[] a = new int[n]; for(int i = 0;i < n;i++)a[i] = ni(); return a; } private int ni() { int num = 0, b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private long nl() { long num = 0; int b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); } }
Main.java:17: error: ')' or ',' expected Dijkstra dijkstra = new Dijkstra((2*m+n+10); ^ 1 error
s203672704
p04003
C++
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <sstream> #include <functional> #include <map> #include <string> #include <cstring> #include <vector> #include <queue> #include <stack> #include <deque> #include <set> #include <list> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> P; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const ll INF = 1LL<<29; const ll mod = 1e9+7; #define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i)) #define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d)) #define all(v) (v).begin(), (v).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset((m),(v),sizeof(m)) #define chmin(X,Y) ((X)>(Y)?X=(Y),true:false) #define chmax(X,Y) ((X)<(Y)?X=(Y),true:false) #define fst first #define snd second #define UNIQUE(x) (x).erase(unique(all(x)),(x).end()) template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;} #define N 100010 int d[N]; vector<P> g[N]; int main(){ ll n, m; cin>>n>>m; rep(i, m){ int u, v, c; cin>>u>>v>>c; u--; v--; c--; g[u].push_back(P(v, c)); g[v].push_back(P(u, c)); } deque<P> q; q.push_front(P(0, -1)); fill(d, d+n, INF); d[0] = 0; while(!q.empty()){ P p = q.front(); q.pop_front(); for(auto x: g[p.fst]){ int w = e[p.fst].count(x.snd)!=1; if(d[p.fst]+w<d[x.fst]){ d[x.fst] = d[p.fst]+w; if(w==0) q.push_front(x); else q.push_back(x); } else if(d[p.fst]+w==d[x.fst]){ for(auto y: g[x.fst]){ if(y.fst==p.fst) continue; if(x.snd!=y.snd) continue; if(d[y.fst]>d[x.fst]){ if(w==0) q.push_front(x); else q.push_back(x); } } } } } cout<<(d[n-1]==INF?-1:d[n-1])<<endl; return 0; }
a.cc: In function 'int main()': a.cc:59:33: error: 'e' was not declared in this scope 59 | int w = e[p.fst].count(x.snd)!=1; | ^
s578184328
p04003
C++
#include <bits/stdc++.h>   using namespace std;   #define INF 1001000100010001000 #define MOD 1000000007 #define EPS 1e-10 #define int long long #define rep(i, N) for (int i = 0; i < N; i++) #define Rep(i, N) for (int i = 1; i < N; i++) #define For(i, a, b) for (int i = (a); i < (b); i++) #define pb push_back #define eb emplace_back #define mp make_pair #define i_i pair<int, int> #define vi vector<int> #define vvi vector<vi > #define vb vector<bool> #define vvb vector<vb > #define vp vector< i_i > #define all(a) (a).begin(), (a).end() #define Int(x) int x; cin >> x; #define int2(x, y) Int(x); Int(y); #define int3(x, y, z) Int(x); int2(y, z); #define fir first #define sec second #define ffir first.first #define fsec first.second #define sfir second.first #define ssec second.second   //int dxy[5] = {0, 1, 0, -1, 0}; // // assign avl ncm dijkstra geo2 kruskal graph uf lca BIT // matrix dinic next_combination topcoder lcm vi st gin   typedef int Weight; typedef int Flow; struct Edge { int s, d; Weight w; Flow c; Edge() {}; Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {}; }; bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; } bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; } inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }   typedef vector<Edge> Edges; typedef vector<Edges> Graph; typedef vector<Weight> Array; typedef vector<Array> Matrix;   void addArc(Graph &g, int s, int d, int w = 1) { g[s].push_back(Edge(s, d, w)); } void addEdge(Graph &g, int a, int b, int w = 1) { addArc(g, a, b, w); addArc(g, b, a, w); }   Graph g;   //単一始点最短経路(負閉路なし) //Dijkstra O((|E|+|V|)log|V|) //dist: 始点から各頂点までの最短距離, assignされるので安心して欲しい //戻り値: 最短経路木の親頂点(根は-1) vector<int> dijkstra(const Graph &g, int s, Array &dist) { int n = g.size(); assert(s < n); enum { WHITE, GRAY, BLACK }; vector<int> color(n, WHITE); color[s] = GRAY; vector<int> prev(n, -1); dist.assign(n, INF); dist[s] = 0; //始点からの最短距離 子 親 typedef pair< int, pair < int, int > > State; priority_queue<State, vector<State>, greater<State> > pq; pq.push(State(0, i_i(s, -1))); while (pq.size()) { Weight d = pq.top().first; int v = pq.top().second.first, u = pq.top().second.second; pq.pop(); if (dist[v] < d)continue; color[v] = BLACK; prev[v] = u; for (int i = 0; i < g[v].size(); i++) { Edge e = g[v][i]; if (color[e.d] == BLACK)continue; if (dist[e.d] > dist[v] + e.w) { dist[e.d] = dist[v] + e.w; pq.push(State(dist[e.d], i_i(e.d, v))); color[e.d] = GRAY; } } } return prev; }   map<i_i, int> id; int ptr;   int getid(int a, int b) { if (id.find(i_i(a, b)) == id.end()) { id.insert(mp(i_i(a, b), ptr)); g.pb(Edges()); return ptr++; } else { return id[i_i(a, b)]; } }   signed main() { std::ios::sync_with_stdio(false); std::cin.tie(0);   int2(n, m); if (!m) { if (n == 1) cout << 0 << endl; else cout << -1 << endl; return 0; } vvi ec(n); for (int i = 0; i < m; i++) { int tmpx, tmpy, color; cin >> tmpx >> tmpy >> color; tmpx--; tmpy--; ec[tmpx].pb(color); ec[tmpy].pb(color); int a = getid(tmpx, color), b = getid(tmpy, color); addEdge(g, a, b, 0); } rep(i, n) { for (int j : ec[i]) { int from = getid(i, j), to = getid(i, -1); addArc(g, from, to, 0); addArc(g, to, from, 1); } } //cout << g.size() << endl; vi dist; dijkstra(g, getid(0, -1), dist); int tmp = getid(n-1, -1); if (tmp >= dist.size()) { cout << -1 << endl; return 0; } if (dist[getid(n-1, -1)] == INF) cout << -1 << endl; else cout << dist[getid(n-1, -1)] << endl;   return 0; }
a.cc:2:1: error: extended character   is not valid in an identifier 2 |   | ^ a.cc:4:1: error: extended character   is not valid in an identifier 4 |   | ^ a.cc:31:1: error: extended character   is not valid in an identifier 31 |   | ^ a.cc:35:1: error: extended character   is not valid in an identifier 35 |   | ^ a.cc:46:1: error: extended character   is not valid in an identifier 46 |   | ^ a.cc:51:1: error: extended character   is not valid in an identifier 51 |   | ^ a.cc:59:1: error: extended character   is not valid in an identifier 59 |   | ^ a.cc:61:1: error: extended character   is not valid in an identifier 61 |   | ^ a.cc:95:1: error: extended character   is not valid in an identifier 95 |   | ^ a.cc:98:1: error: extended character   is not valid in an identifier 98 |   | ^ a.cc:109:1: error: extended character   is not valid in an identifier 109 |   | ^ a.cc:114:1: error: extended character   is not valid in an identifier 114 |   | ^ a.cc:148:1: error: extended character   is not valid in an identifier 148 |   | ^ a.cc:2:1: error: '\U000000a0' does not name a type 2 |   | ^ a.cc:4:1: error: '\U000000a0' does not name a type 4 |   | ^ a.cc:39:15: error: 'Weight' does not name a type 39 | int s, d; Weight w; Flow c; | ^~~~~~ a.cc:41:24: error: 'Weight' has not been declared 41 | Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {}; | ^~~~~~ a.cc: In constructor 'Edge::Edge(long long int, long long int, int)': a.cc:41:52: error: class 'Edge' does not have any field named 'w' 41 | Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {}; | ^ a.cc: In function 'bool operator<(const Edge&, const Edge&)': a.cc:43:60: error: 'const struct Edge' has no member named 'w' 43 | bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; } | ^ a.cc:43:67: error: 'const struct Edge' has no member named 'w' 43 | bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; } | ^ a.cc: At global scope: a.cc:45:8: error: 'ostream' does not name a type 45 | inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); } | ^~~~~~~ a.cc:46:1: error: '\U000000a0' does not name a type 46 |   | ^ a.cc:48:9: error: 'vector' does not name a type 48 | typedef vector<Edges> Graph; | ^~~~~~ a.cc:49:9: error: 'vector' does not name a type 49 | typedef vector<Weight> Array; | ^~~~~~ a.cc:50:9: error: 'vector' does not name a type 50 | typedef vector<Array> Matrix; | ^~~~~~ a.cc:51:1: error: '\U000000a0' does not name a type 51 |   | ^ a.cc:55:6: error: variable or field 'addEdge' declared void 55 | void addEdge(Graph &g, int a, int b, int w = 1) { | ^~~~~~~ a.cc:55:14: error: 'Graph' was not declared in this scope; did you mean 'isgraph'? 55 | void addEdge(Graph &g, int a, int b, int w = 1) { | ^~~~~ | isgraph a.cc:55:21: error: 'g' was not declared in this scope 55 | void addEdge(Graph &g, int a, int b, int w = 1) { | ^ a.cc:8:13: error: expected primary-expression before 'long' 8 | #define int long long | ^~~~ a.cc:55:24: note: in expansion of macro 'int' 55 | void addEdge(Graph &g, int a, int b, int w = 1) { | ^~~ a.cc:8:13: error: expected primary-expression before 'long' 8 | #define int long long | ^~~~ a.cc:55:31: note: in expansion of macro 'int' 55 | void addEdge(Graph &g, int a, int b, int w = 1) { | ^~~ a.cc:8:13: error: expected primary-expression before 'long' 8 | #define int long long | ^~~~ a.cc:55:38: note: in expansion of macro 'int' 55 | void addEdge(Graph &g, int a, int b, int w = 1) { | ^~~ a.cc:59:1: error: '\U000000a0' does not name a type 59 |   | ^ a.cc:61:1: error: '\U000000a0' does not name a type 61 |   | ^ a.cc:95:1: error: '\U000000a0' does not name a type 95 |   | ^ a.cc:98:1: error: '\U000000a0' does not name a type 98 |   | ^ a.cc:109:1: error: '\U000000a0' does not name a type 109 |   | ^
s984197356
p04003
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> #include <cstring> #include <deque> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) #define CLR(mat) memset(mat, 0, sizeof(mat)) typedef long long ll; typedef pair<int, int> P; typedef pair<P, P> PP; priority_queue<PP, vector<PP>, greater<PP> > Q; vector<vector<P> > G; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, M; cin >> N >> M; G.resize(N+1); FOR(i,0,M) { int p, q, c; cin >> p >> q >> c; G[p].push_back(P(q, c)); G[q].push_back(P(p, c)); } int d[N+1]; FOR(i,0,N+1) d[i] = 1e9; d[1] = 0; Q.push(PP(P(0, 1), P(0, 0))); while(!Q.empty()) { PP pp = Q.top(); Q.pop(); int dd = pp.first.first; int now = pp.first.second; int from = pp.second.first; int c = pp.second.second; if(d[now] < dd) continue; if(now == N) { cout << dd << endl; return 0; } d[now] = dd; for(auto to : G[now]) { int a = to.first; int b = to.second; if(a == from) continue; if(c == b) { if(d[a] >= dd) Q.push(PP(P(dd, a), P(now, b))); } elseif(d[a] >= dd + 1) Q.push(PP(P(dd + 1, a), P(now, b))); } } if(d[N] == 1e9) cout << -1 << endl; else cout << d[N] << endl; return 0; }
a.cc: In function 'int main()': a.cc:59:7: error: 'elseif' was not declared in this scope 59 | elseif(d[a] >= dd + 1) Q.push(PP(P(dd + 1, a), P(now, b))); | ^~~~~~
s780020039
p04003
C++
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define f first #define s second typedef pair<int,int> pii; int n,m; vector<pii> edge[200200]; vector<int> col[1001000]; vector<int> ned[500500]; int colour[200200],x[200200],l[200200]; int dist[500500]; int main(){ scanf("&d &d", &n, &m); for (int i=1;i<=m;i++){ int p,q,c; scanf("%d %d %d", &p, &q, &c); edge[p].pb(mp(c,q)); edge[q].pb(mp(c,p)); col[c].pb(q); col[c].pb(p); } for (int i=1;i<=n;i++){ sort(edge[i].begin(),edge[i].end()); } memset(colour,0,sizeof colour); memset(x,0,sizeof x); memset(l,0,sizeof l); int nw=n+1; for (int co=1;co<=1000000;co++){ if (!col[co].size()) continue; for (int k=0;k<col[co].size();k++){ int p=col[co][k]; if (colour[p]==co) continue; colour[p]=co; queue<int> q; q.push(p); while (!q.empty()){ int b=q.front(); q.pop(); while (l[b]<edge[b].size()){ int c=edge[b][l[b]].f; if (c!=co) break; int pp=edge[b][l[b]].s; if (colour[pp]!=co){ colour[pp]=co; q.push(pp); } l[b]++; } ned[b].pb(nw); ned[nw].pb(b); } nw++; } } for (int i=1;i<=nw;i++) dist[i]=-2; queue<int> q; q.push(1); dist[1]=0; while (!q.empty()){ int b=q.front(); q.pop(); for (int i=0;i<ned[b].size();i++){ int p=ned[b][i]; if (dist[p]==-2){ dist[p]=dist[b]+1; q.push(p); } } } printf("%d\n", &dist[n]/2); return 0; }
a.cc: In function 'int main()': a.cc:75:32: error: invalid operands of types 'int*' and 'int' to binary 'operator/' 75 | printf("%d\n", &dist[n]/2); | ~~~~~~~~^~ | | | | int* int
s921650784
p04003
C++
#include <bits/stdc++.h> #define _overload(_1,_2,_3,name,...) name #define _rep(i,n) _range(i,0,n) #define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i) #define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__) #define _rrep(i,n) _rrange(i,n,0) #define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i) #define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__) #define _all(arg) begin(arg),end(arg) #define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg)) #define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary) #define clr(a,b) memset((a),(b),sizeof(a)) #define bit(n) (1LL<<(n)) // #define DEBUG #ifdef DEBUG #define dump(...) fprintf(stderr, __VA_ARGS__) #else #define dump(...) #endif template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;} template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;} using namespace std; using ll=long long; using vi=vector<int>; using vll=vector<ll>; const double EPS = 1e-10; const double PI = acos(-1.0); const int inf =INT_MAX; const ll mod=1000000007LL; const int dx[4]={1,0,-1,0}; const int dy[4]={0,1,0,-1}; ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;} ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;} ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;} ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;} ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);} random_device rd; mt19937 mt(rd()); uniform_int_distribution<int> dice(1,6); uniform_real_distribution<double> score(0.0,10.0); int main(void){ cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; using Edge = tuple<int, int>; vector<vector<Edge>> G(n); rep(loop, m){ int a, b, c; cin >> a >> b >> c; a--, b--; G[a].emplace_back(Edge(b, c)); G[b].emplace_back(Edge(a, c)); } using Elem = tuple<int, int, int>; priority_queue<Elem, vector<Elem>, greater<Elem>> q; int sz = 0; unordered_map<pair<int, int>, int> p2i; rep(i, n){ set<int> s = {0}; for(auto& e : G[i]){ s.insert(get<1>(e)); } for(auto& e : s){ p2i[make_pair(i, e)] = sz++; } } vi min_dist(sz, inf); q.push(Elem(0, 0, 0)); min_dist[0] = 0; int res = -1; while(q.size()){ int cost, v, pc; tie(cost, v, pc) = q.top(); q.pop(); if(cost != min_dist[p2i[make_pair(v, pc)]]) continue; if(v == n - 1){ res = cost; break; } for(auto& e : G[v]){ int nv, nc; tie(nv, nc) = e; int ncost = cost; if(pc != 0 and nc != pc){ continue; } if(pc == 0) ncost++; int idx = p2i[make_pair(nv, nc)]; if(chmin(min_dist[idx], ncost)){ min_dist[idx] = ncost; q.push(Elem(ncost, nv, nc)); } } if(pc != 0){ int idx = p2i[make_pair(v, 0)]; if(chmin(min_dist[idx], cost)){ min_dist[idx] = cost; q.push(Elem(cost, v, 0)); } } } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:70:40: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 70 | unordered_map<pair<int, int>, int> p2i; | ^~~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h: At global scope: /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: err
s328015336
p04003
C++
#include <bits/stdc++.h> #define _overload(_1,_2,_3,name,...) name #define _rep(i,n) _range(i,0,n) #define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i) #define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__) #define _rrep(i,n) _rrange(i,n,0) #define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i) #define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__) #define _all(arg) begin(arg),end(arg) #define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg)) #define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary) #define clr(a,b) memset((a),(b),sizeof(a)) #define bit(n) (1LL<<(n)) // #define DEBUG #ifdef DEBUG #define dump(...) fprintf(stderr, __VA_ARGS__) #else #define dump(...) #endif template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;} template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;} using namespace std; using ll=long long; using vi=vector<int>; using vll=vector<ll>; const double EPS = 1e-10; const double PI = acos(-1.0); const int inf =INT_MAX; const ll mod=1000000007LL; const int dx[4]={1,0,-1,0}; const int dy[4]={0,1,0,-1}; ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;} ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;} ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;} ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;} ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);} random_device rd; mt19937 mt(rd()); uniform_int_distribution<int> dice(1,6); uniform_real_distribution<double> score(0.0,10.0); int main(void){ cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; using Edge = tuple<int, int>; vector<vector<Edge>> G(n); rep(loop, m){ int a, b, c; cin >> a >> b >> c; a--, b--; G[a].emplace_back(Edge(b, c)); G[b].emplace_back(Edge(a, c)); } using Elem = tuple<int, int, int>; priority_queue<Elem, vector<Elem>, greater<Elem>> q; int sz = 0; unorderd_map<pair<int, int>, int> p2i; rep(i, n){ set<int> s = {0}; for(auto& e : G[i]){ s.insert(get<1>(e)); } for(auto& e : s){ p2i[make_pair(i, e)] = sz++; } } vi min_dist(sz, inf); q.push(Elem(0, 0, 0)); min_dist[0] = 0; int res = -1; while(q.size()){ int cost, v, pc; tie(cost, v, pc) = q.top(); q.pop(); if(cost != min_dist[p2i[make_pair(v, pc)]]) continue; if(v == n - 1){ res = cost; break; } for(auto& e : G[v]){ int nv, nc; tie(nv, nc) = e; int ncost = cost; if(pc != 0 and nc != pc){ continue; } if(pc == 0) ncost++; int idx = p2i[make_pair(nv, nc)]; if(chmin(min_dist[idx], ncost)){ min_dist[idx] = ncost; q.push(Elem(ncost, nv, nc)); } } if(pc != 0){ int idx = p2i[make_pair(v, 0)]; if(chmin(min_dist[idx], cost)){ min_dist[idx] = cost; q.push(Elem(cost, v, 0)); } } } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:70:5: error: 'unorderd_map' was not declared in this scope 70 | unorderd_map<pair<int, int>, int> p2i; | ^~~~~~~~~~~~ a.cc:70:32: error: expected primary-expression before ',' token 70 | unorderd_map<pair<int, int>, int> p2i; | ^ a.cc:70:34: error: expected primary-expression before 'int' 70 | unorderd_map<pair<int, int>, int> p2i; | ^~~ a.cc:77:13: error: 'p2i' was not declared in this scope 77 | p2i[make_pair(i, e)] = sz++; | ^~~ a.cc:87:29: error: 'p2i' was not declared in this scope 87 | if(cost != min_dist[p2i[make_pair(v, pc)]]) continue; | ^~~ a.cc:101:23: error: 'p2i' was not declared in this scope 101 | int idx = p2i[make_pair(nv, nc)]; | ^~~ a.cc:109:23: error: 'p2i' was not declared in this scope 109 | int idx = p2i[make_pair(v, 0)]; | ^~~
s282538766
p04003
C++
//A,Elebereth Gilthoniel mantae! //For Temeria! #include<iostream> #include<algorithm> #include<cmath> #include<string> #include<vector> #include<set> #include<cstdio> #include<map> #include<stack> #include<queue> #include<cstring> using namespace std; const long long maxn=2e6+1e5; vector<pair<long long,long long> > v[maxn];vector<long long> col[maxn];long long vis[maxn]; long long bark[maxn];vector<long long> qzr[maxn];long long ful; long long dis[maxn]; int main() { long long n,m;cin>>n>>m; for(long long i=0;i<m;i++) { long long a,b,c;cin>>a>>b>>c; v[a].push_back(make_pair(c,b));v[b].push_back(make_pair(c,a)); col[c].push_back(a);col[c].push_back(b); } for(long long i=1;i<=n;i++) { sort(v[i].begin(),v[i].end()); } ful=1e6+5; for(long long asd=1;asd<=1e6+500;asd++) { if(col[asd].size()==0) continue; for(long long it=0;it<col[asd].size();it++) { long long p=col[asd][it]; if(vis[p]==asd) continue; queue<long long> q;vector<long long> kl;kl.clear(); q.push(p);vis[p]=asd;kl.push_back(p); while(!q.empty()) { if(q.size()==0) break; long long t=q.front();q.pop(); for(long long i=max(bark[t]-10,0);i<v[t].size();i++) { pair<long long,long long> u=v[t][i]; if(vis[u.second]==asd) continue; if(u.first>asd) { bark[t]=i;break; } if(u.first<asd) { continue; //bark[t]=i;break; } kl.push_back(u.second);q.push(u.second);vis[u.second]=asd; } } for(long long i=0;i<kl.size();i++) { // cout<<kl[i]<<" "; long long t=kl[i];qzr[t].push_back(ful),qzr[ful].push_back(t); }//cout<<"\n"; ful++; } } memset(dis,-1,sizeof(dis)); priority_queue<pair<long long,long long> > q; q.push(make_pair(-0,1));dis[1]=0; while(!q.empty()) { if(q.size()==0) break; long long t=(q.top()).second;q.pop(); for(long long i=0;i<qzr[t].size();i++) { long long j=qzr[t][i]; if(dis[j]==-1) { dis[j]=dis[t]+1;q.push(make_pair(-dis[j],j)); } } } if(dis[n]==-1) dis[n]--; cout<<dis[n]/2; return 0; }
a.cc: In function 'int main()': a.cc:46:52: error: no matching function for call to 'max(long long int, int)' 46 | for(long long i=max(bark[t]-10,0);i<v[t].size();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: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:46:52: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 46 | for(long long i=max(bark[t]-10,0);i<v[t].size();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:46:52: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 46 | for(long long i=max(bark[t]-10,0);i<v[t].size();i++) | ~~~^~~~~~~~~~~~~~
s537656045
p04003
C++
#include <bits/stdc++.h> using namespace std; #define iinf 2000000000 #define linf 1000000000000000000 #define ulinf 10000000000000000000ull #define MOD 1000000007 #define lson(v) ((v)<<1) #define rson(v) (((v)<<1)^1) #define mpr make_pair typedef long long LL; typedef unsigned long long ULL; typedef unsigned long UL; typedef unsigned short US; typedef pair < int , int > pii; clock_t __stt; inline void TStart(){__stt=clock();} inline void TReport(){printf("Taken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);} template < typename T > T MIN(T a,T b){return a<b?a:b;} template < typename T > T MAX(T a,T b){return a<b?a:b;} template < typename T > T ABS(T a){return a>0?a:(-a);} template < typename T > UMIN(T &a,T b){if(b<a) a=b;} template < typename T > UMAX(T &a,T b){if(b>a) a=b;} int n,m,cur,u[200005],v[200005],c[200005],dist[200005]; vector < pii > G[1000000]; map < int , int > mp[200005]; int main(){ memset(dist,-1,sizeof(dist)); scanf("%d%d",&n,&m); int xb,x2; for(xb=0;xb<m;++xb){ scanf("%d%d%d",u+xb,v+xb,c+xb);--c[xb]; mp[--u[xb]][c[xb]]=mp[--v[xb]][c[xb]]=1; } #ifdef LOCAL TStart(); #endif cur=n; for(x2=0;x2<n;++x2){ map < int , int > ::iterator it; for(it=mp[x2].begin();it!=mp[x2].end();++it){ it->second=cur; G[cur].push_back(make_pair(x2,1)); G[x2].push_back(make_pair(cur,1)); ++cur; } } for(xb=0;xb<m;++xb){ G[mp[u[xb]][c[xb]]].push_back(make_pair(mp[v[xb]][c[xb]],0)); G[mp[v[xb]][c[xb]]].push_back(make_pair(mp[u[xb]][c[xb]],0)); } deque < int > dq; dq.clear(); dq.push_back(0); dist[0]=0; while(!dq.empty()){ if(dist[n-1]>=0) break; int cv=dq.front(); dq.pop_front(); for(xb=G[cv].size()-1;xb>=0;--xb){ pii &E=G[cv][xb]; if(dist[E.first]==-1 || dist[cv]+E.second<dist[E.first]){ dist[E.first]=dist[cv]+E.second; if(E.second) dq.push_back(E.first); else dq.push_front(E.first); if(E.first==n-1) break; } } } printf("%d\n",dist[n-1]>>1); #ifdef LOCAL TReport(); #endif return 0; }
a.cc:21:25: error: ISO C++ forbids declaration of 'UMIN' with no type [-fpermissive] 21 | template < typename T > UMIN(T &a,T b){if(b<a) a=b;} | ^~~~ a.cc: In function 'int UMIN(T&, T)': a.cc:21:52: warning: no return statement in function returning non-void [-Wreturn-type] 21 | template < typename T > UMIN(T &a,T b){if(b<a) a=b;} | ^ a.cc: At global scope: a.cc:22:25: error: ISO C++ forbids declaration of 'UMAX' with no type [-fpermissive] 22 | template < typename T > UMAX(T &a,T b){if(b>a) a=b;} | ^~~~ a.cc: In function 'int UMAX(T&, T)': a.cc:22:52: warning: no return statement in function returning non-void [-Wreturn-type] 22 | template < typename T > UMAX(T &a,T b){if(b>a) a=b;} | ^
s718957603
p04003
C++
#include<ctime> #include<iostream> #include<algorithm> #include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #include<cassert> #include<string> #include<sstream> #include<fstream> #include<deque> #include<queue> #include<vector> #include<map> #include<list> #include<stack> #include<set> #include<bitset> #include<iomanip> #include<utility> #include<functional> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cwchar> #include<cwctype> #include<exception> #include<locale> #include<numeric> #include<new> #include<stdexcept> #include<limits> using namespace std; #define ll long long #define INF 1e9 #define rep(i,n) for(int (i)=0;(i)<n;i++) #define REP(i,n) for(int (i)=1;(i)<=n;i++) #define mk(a,b) make_pair(a,b) #define fi first #define se second #define pii pair<int,int> #define sz(s) s.size() #define all(s) (s.begin(),s.end()) inline void Fail(){ printf("0"); exit(0); } inline void Unique(vector<int>&v){ sort(v.begin(),v.end()); v.resize(unique(v.begin(),v.end())-v.begin()); } inline int Get(vector<int>v,int x){ return lower_bound(v.begin(),v.end(),x)-v.begin(); } const int maxn=2000005; int n,m,cnt,ans=INF; vector<pii>edge[maxn]; vector<int>col[maxn],index[maxn]; int dist[maxn],a[maxn],b[maxn],c[maxn]; void Dijkstra(){ priority_queue<pii,vector<pii>,greater<pii> >q; rep(i,maxn)dist[i]=INF; dist[0]=0; q.push(mk(0,0)); while(!q.empty()){ pii x=q.top();q.pop(); if(x.first!=dist[x.second])continue; rep(i,edge[x.second].size()){ pii y=edge[x.second][i]; if(dist[x.second]+y.second<dist[y.first]){ dist[y.first]=dist[x.second]+y.second; q.push(mk(dist[y.first],y.first)); } } } } int main(){ scanf("%d%d",&n,&m); rep(i,m){ scanf("%d%d%d",&a[i],&b[i],&c[i]); a[i]--;b[i]--; col[a[i]].push_back(c[i]); col[b[i]].push_back(c[i]); } cnt=n; rep(i,n){ Unique(col[i]); rep(j,col[i].size())index[i].push_back(cnt++); } rep(i,m){ int x=index[a[i]][Get(col[a[i]],c[i])]; int y=index[b[i]][Get(col[b[i]],c[i])]; edge[x].push_back(make_pair(y,0)); edge[y].push_back(make_pair(x,0)); } rep(i,n){ rep(j,index[i].size()){ int x=index[i][j]; edge[i].push_back(make_pair(x,1)); edge[x].push_back(make_pair(i,0)); } } Dijkstra(); rep(i,index[n-1].size()){ int x=index[n-1][i]; ans=min(ans,dist[x]); } printf("%d",(ans==INF)?-1:ans); return 0; }
a.cc:69:32: error: 'std::vector<int> index [2000005]' redeclared as different kind of entity 69 | vector<int>col[maxn],index[maxn]; | ^ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from a.cc:7: /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 'int main()': a.cc:101:42: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 101 | rep(j,col[i].size())index[i].push_back(cnt++); | ^ a.cc:104:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 104 | int x=index[a[i]][Get(col[a[i]],c[i])]; | ^ a.cc:105:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 105 | int y=index[b[i]][Get(col[b[i]],c[i])]; | ^ a.cc:110:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 110 | rep(j,index[i].size()){ | ^ a.cc:46:36: note: in definition of macro 'rep' 46 | #define rep(i,n) for(int (i)=0;(i)<n;i++) | ^ a.cc:111:36: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 111 | int x=index[i][j]; | ^ a.cc:117:20: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 117 | rep(i,index[n-1].size()){ | ^ a.cc:46:36: note: in definition of macro 'rep' 46 | #define rep(i,n) for(int (i)=0;(i)<n;i++) | ^ a.cc:118:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 118 | int x=index[n-1][i]; | ^
s645564096
p04003
C++
#include<iostream> #include<vector> #include<algorithm> #include<queue> #include<cstdio> using namespace std; queue<pair<int,int> >q; int n,m,nn; vector<pair<int,int> >v[100010]; vector<int>nv[300010]; bool vis[300010]; int cur[100010]; vector<int>col[1000010]; vector<int>res; void dfs(int x,int c) { vis[x]=true; res.push_back(x); for(int i=cur[x];i<v[x].size();i++) { if(v[x][i].first!=c)break; cur[x]++; int y=v[x][i].second; if(vis[y])continue; dfs(y,c); } } int main() { scanf("%d%d",&n,&m); nn=n; for(int i=1;i<=m;i++) { int x,y,c; scanf("%d%d%d",&x,&y,&c); v[x].push_back(make_pair(c,y)); v[y].push_back(make_pair(c,x)); col[c].push_back(x); col[c].push_back(y); } for(int i=1;i<=n;i++) { sort(v[i].begin(),v[i].end()); } for(int i=1;i<=1000000;i++) { if(!col[i].size())continue; for(int j=0;j<col[i].size();j++) { vis[col[i][j]]=false; } for(int j=0;j<col[i].size();j++) { int x=col[i][j]; if(vis[x])continue; res.clear(); dfs(x,i); nn++; for(int k=0;k<res.size();k++) { nv[nn].push_back(res[k]); nv[res[k]].push_back(nn); } } } memset(vis,false,sizeof(vis)); q.push(make_pair(1,0)); vis[1]=true; while(!q.empty()) { int x=q.front().first,w=q.front().second; q.pop(); if(x==n) { printf("%d",w/2); return 0; } for(int i=0;i<nv[x].size();i++) { int y=nv[x][i]; if(vis[y])continue; vis[y]=true; q.push(make_pair(y,w+1)); } } printf("-1"); return 0; }
a.cc: In function 'int main()': a.cc:66:9: error: 'memset' was not declared in this scope 66 | memset(vis,false,sizeof(vis)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<cstdio> +++ |+#include <cstring> 6 | using namespace std;
s012267174
p04003
C++
#include<iostream> #include<algorithm> #include<vector> #include<queue> #define lol(i,n) for(int i=0;i<n;i++) #define mod 1000000007 typedef long long ll; using namespace std; #include<map> typedef pair<int,int> P; //vector<vector<P> >v;//辺リスト(v[i]には辺が詰まっている vector<P> v[500010]; unordered_map<int,int> u[100010];//頂点リスト(u[頂点][路線]==vでの番号) priority_queue<P,vector<P>,greater<P> >Q; int dis[500010]; int main(){ vector<P> emptyvector; //v.push_back(emptyvector); int n,m; cin>>n>>m; int vsize=1; for(int i=1;i<=n;i++){ //v.push_back(emptyvector); u[i][-1]=vsize; vsize++; } while(m--){ int a,b,train; cin>>a>>b>>train; lol(p,2){ if(u[a][train]==0){ //v.push_back(emptyvector); v[vsize].push_back(make_pair(a,0)); v[a].push_back(make_pair(vsize,1)); u[a][train]=vsize; a=vsize; vsize++; } else{ a=u[a][train]; } swap(a,b); } v[a].push_back(make_pair(b,0)); v[b].push_back(make_pair(a,0)); } //↓ Dijkstra ↓ lol(i,vsize)dis[i]=mod; Q.push(make_pair(1,0)); while(!Q.empty()){ int a=Q.top().first,b=Q.top().second; Q.pop(); if(dis[a]<=b)continue; dis[a]=b; for(int i=0;i<v[a].size();i++){ int pnt=v[a][i].first,cost=v[a][i].second+b; if(dis[pnt]<=cost)continue; Q.push(make_pair(v[a][i].first,v[a][i].second+b)); } } int tmp=dis[u[n][-1]]; cout<<(tmp==mod?-1:tmp)<<endl; return 0; }
a.cc:15:1: error: 'unordered_map' does not name a type 15 | unordered_map<int,int> u[100010];//頂点リスト(u[頂点][路線]==vでの番号) | ^~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:29:17: error: 'u' was not declared in this scope 29 | u[i][-1]=vsize; | ^ a.cc:36:28: error: 'u' was not declared in this scope 36 | if(u[a][train]==0){ | ^ a.cc:68:21: error: 'u' was not declared in this scope 68 | int tmp=dis[u[n][-1]]; | ^
s389653251
p04003
C++
#include<iostream> #include<algorithm> #include<vector> #include<queue> #define lol(i,n) for(int i=0;i<n;i++) #define mod 1000000007 typedef long long ll; using namespace std; #include<map> typedef pair<int,int> P; //vector<vector<P> >v;//辺リスト(v[i]には辺が詰まっている vector<P> v[500010]; unordered_map<int,int> u[100010];//頂点リスト(u[頂点][路線]==vでの番号) priority_queue<P,vector<P>,greater<P> >Q; int dis[500010]; int main(){ vector<P> emptyvector; //v.push_back(emptyvector); int n,m; cin>>n>>m; int vsize=1; for(int i=1;i<=n;i++){ //v.push_back(emptyvector); u[i][-1]=vsize; vsize++; } while(m--){ int a,b,train; cin>>a>>b>>train; lol(p,2){ if(u[a][train]==0){ //v.push_back(emptyvector); v[vsize].push_back(make_pair(a,0)); v[a].push_back(make_pair(vsize,1)); u[a][train]=vsize; a=vsize; vsize++; } else{ a=u[a][train]; } swap(a,b); } v[a].push_back(make_pair(b,0)); v[b].push_back(make_pair(a,0)); } //↓ Dijkstra ↓ lol(i,vsize)dis[i]=mod; Q.push(make_pair(1,0)); while(!Q.empty()){ int a=Q.top().first,b=Q.top().second; Q.pop(); if(dis[a]<=b)continue; dis[a]=b; for(int i=0;i<v[a].size();i++){ int pnt=v[a][i].first,cost=v[a][i].second+b; if(dis[pnt]<=cost)continue; Q.push(make_pair(v[a][i].first,v[a][i].second+b)); } } int tmp=dis[u[n][-1]]; cout<<(tmp==mod?-1:tmp)<<endl; return 0; }
a.cc:15:1: error: 'unordered_map' does not name a type 15 | unordered_map<int,int> u[100010];//頂点リスト(u[頂点][路線]==vでの番号) | ^~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:29:17: error: 'u' was not declared in this scope 29 | u[i][-1]=vsize; | ^ a.cc:36:28: error: 'u' was not declared in this scope 36 | if(u[a][train]==0){ | ^ a.cc:68:21: error: 'u' was not declared in this scope 68 | int tmp=dis[u[n][-1]]; | ^
s636201353
p04003
C++
#include<bits/stdc++.h> #define int long long #define fi first #define se second #define PB push_back using namespace std; typedef pair<int, int> P1; typedef pair<int, pair<int, int> > P2; static const int INF = 1ll<<60; static const int dx[] = { 1, -1, 0, 0, }; static const int dy[] = { 0, 0, 1, -1 }; static const int mod = 1000000007; int N,M; int ans=INF; unordered_map < P1,vector<P2> > E; unordered_map < P1,int > dist; void dijkstra(int s){ priority_queue< P2,vector<P2>,greater<P2> > pq; dist[P1(s,0)] = 0; dist[P1(N-1,0)] = INF; pq.push(P2(0,P1(s,0))); while(!pq.empty()){ P2 p = pq.top(); pq.pop(); int v = p.second.first; int c = p.second.second; if(dist[P1(v,c)]<p.first)continue; for(auto u : E[P1(v,c)]){ P1 to = P1(u.first,u.second.first); int cost = u.second.second; if(dist[to]>dist[P1(v,c)]+cost){ dist[to] = dist[P1(v,c)]+cost; pq.push(P2(dist[to],to)); } } } ans = dist[P1(N-1,0)]; } signed main(){ cin>>N>>M; for(int i=0;i<M;++i){ int a,b,c; cin>>a>>b>>c; a--,b--; E[P1(a,c)].PB(P2(b,P1(c,0))); E[P1(b,c)].PB(P2(a,P1(c,0))); E[P1(a,c)].PB(P2(a,P1(0,1))); E[P1(a,0)].PB(P2(a,P1(c,1))); E[P1(b,c)].PB(P2(b,P1(0,1))); E[P1(b,0)].PB(P2(b,P1(c,1))); ///////////////////////////// dist[P1(a,c)] = INF; dist[P1(b,c)] = INF; dist[P1(a,c)] = INF; dist[P1(a,0)] = INF; dist[P1(b,c)] = INF; dist[P1(b,0)] = INF; } dijkstra(0); if(ans==INF)cout<<-1<<endl; else cout<<ans/2<<endl; }
a.cc:17:33: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = std::vector<std::pair<long long int, std::pair<long long int, long long int> > >; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > > >]' 17 | unordered_map < P1,vector<P2> > E; | ^ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = std::vector<std::pair<long long int, std::pair<long long int, long long int> > >; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > > >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<long long int, long long int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<long long int, long long int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<long long int, long long int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long long int, long long int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long long int, long long int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<long long int, long long int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enu
s728532427
p04003
C++
#include<iostream> #include<cstdio> #include<vector> #include<queue> using namespace std; int n,m,x,y,z,dist[111111]; vector<pair<int,int> > g[111111]; queue<pair<int,int> > q; int main() { scanf("%d%d",&n,&m); for (int i=1;i<=m;i++) { scanf("%d%d%d",&x,&y,&z); g[x].push_back(make_pair(y,z)); g[y].push_back(make_pair(x,z)); } for (int i=1;i<=n;i++) dist[i]=1e9; dist[1]=0; for (int i=0;i<g[1].size();i++) { int =g[1][i].first,val=g[1][i].second; dist[to]=1; q.push(make_pair(to,val)); } while(!q.empty()) { int x=q.front().first,val=q.front().second; q.pop(); for (int i=0;i<g[x].size();i++) { int to=g[x][i].first,k=g[x][i].second; if (k==val && dist[to]>dist[x]) { dist[to]=dist[x]; q.push(make_pair(to,val)); } else if (dist[to]>dist[x]+1) { dist[to]=dist[x]+1; q.push(make_pair(to,k)); } } } if (dist[n]==1e9) printf("-1\n"); else printf("%d\n",dist[n]); return 0; }
a.cc: In function 'int main()': a.cc:22:21: error: expected unqualified-id before '=' token 22 | int =g[1][i].first,val=g[1][i].second; | ^ a.cc:23:22: error: 'to' was not declared in this scope; did you mean 'tm'? 23 | dist[to]=1; | ^~ | tm a.cc:24:37: error: 'val' was not declared in this scope 24 | q.push(make_pair(to,val)); | ^~~
s484759289
p04003
C++
#pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <cstring> #include <vector> #include <tuple> #include <bitset> #include <queue> #include <complex> #include <set> #include <map> #include <stack> #include <list> #include <fstream> #include <random> //#include <time.h> #include <ctime> #pragma endregion //#include ///////// #define REP(i, x, n) for(int i = x; i < n; ++i) #define rep(i,n) REP(i,0,n) #define ALL(X) X.begin(), X.end() ///////// #pragma region typedef typedef long long LL; typedef long double LD; typedef unsigned long long ULL; typedef std::pair<LL,LL> PLL;// typedef std::pair<int,int> PII;// #pragma endregion //typedef ////定数 const int INF = (int)1e9; const LL MOD = (LL)1e9+7; const LL LINF = (LL)1e18+20; const double PI = acos(-1.0); const double EPS = 1e-9; ///////// using namespace::std; vector< vector<edge_base> > gra; int use_color = -2; set<int> visit; void dfs(int curr,int prev,int prev_color,int set_color){ int size = gra[curr].size(); for(int i=0;i<size;++i){ int to = gra[curr][i].to; if( curr == to ) continue;//戻らない int color = gra[curr][i].cost; if( color < 0 ){//乗り換え済み continue; } if( prev_color == -1 ){ visit.insert( to ); gra[curr][i].cost = use_color;//連結成分にする。 dfs( to, curr, color, use_color ); --use_color; }else if( prev_color == color ){ gra[curr][i].cost = use_color; visit.insert( to ); dfs( to, curr, color, use_color ); } } } void solve(){ int N,M; cin >> N >> M; gra.resize(N); while(M--){ int P,Q,C; cin >> P >> Q >> C; --P;--Q; gra[P].push_back( make_edge_base(Q,C) ); gra[Q].push_back( make_edge_base(P,C) ); } //// int visit_num = 1;//0番には行っている。 vector<bool> start(N,false); set<int> next; next.insert(0); int ans = 0; while( next.size() != 0){ ++ans; set<int>::iterator itr,end; itr = next.begin(); end = next.end(); for(;itr!=end;++itr){ dfs( *itr,-1,-1,-1); } if( visit.find(N-1) != visit.end() ){ cout << ans << endl; return; } { set<int> zero; next = visit; visit = zero; } } cout << -1 << endl; } #pragma region main signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;//小数を10進数表示 cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別 solve(); } #pragma endregion //main()
a.cc:50:16: error: 'edge_base' was not declared in this scope 50 | vector< vector<edge_base> > gra; | ^~~~~~~~~ a.cc:50:25: error: template argument 1 is invalid 50 | vector< vector<edge_base> > gra; | ^ a.cc:50:25: error: template argument 2 is invalid a.cc:50:27: error: template argument 1 is invalid 50 | vector< vector<edge_base> > gra; | ^ a.cc:50:27: error: template argument 2 is invalid a.cc: In function 'void dfs(int, int, int, int)': a.cc:54:23: error: invalid types 'int[int]' for array subscript 54 | int size = gra[curr].size(); | ^ a.cc:56:29: error: invalid types 'int[int]' for array subscript 56 | int to = gra[curr][i].to; | ^ a.cc:58:32: error: invalid types 'int[int]' for array subscript 58 | int color = gra[curr][i].cost; | ^ a.cc:64:28: error: invalid types 'int[int]' for array subscript 64 | gra[curr][i].cost = use_color;//連結成分にする。 | ^ a.cc:68:28: error: invalid types 'int[int]' for array subscript 68 | gra[curr][i].cost = use_color; | ^ a.cc: In function 'void solve()': a.cc:77:13: error: request for member 'resize' in 'gra', which is of non-class type 'int' 77 | gra.resize(N); | ^~~~~~ a.cc:83:20: error: invalid types 'int[int]' for array subscript 83 | gra[P].push_back( make_edge_base(Q,C) ); | ^ a.cc:83:35: error: 'make_edge_base' was not declared in this scope 83 | gra[P].push_back( make_edge_base(Q,C) ); | ^~~~~~~~~~~~~~ a.cc:84:20: error: invalid types 'int[int]' for array subscript 84 | gra[Q].push_back( make_edge_base(P,C) ); | ^
s889229551
p04003
C++
#include <iostream> #include <queue> #include <vector> #include <functional> using ll=long long int; constexpr int MAX_N=(int)1e5, constexpr ll INF=(ll)1e9; struct edge{ int to,com; edge()=default; edge(int _t,int _c) : to(_t),com(_c) {} }; struct Node{ int v,com; ll cost; Node()=default; Node(int _v,ll _cost,int _com) : v(_v),cost(_cost),com(_com) {} bool operator< (const Node& rhs) const{ return cost<rhs.cost; } bool operator> (const Node& rhs) const{ return cost>rhs.cost; } }; int n,m; std::vector<edge> G[MAX_N]; ll d[MAX_N]; ll dijkstra(int s,int g){ for(int i=0;i<n;++i) d[i]=INF; std::priority_queue<Node,std::vector<Node>,std::greater<Node>> que; que.emplace(s,d[s]=0,0); while(!que.empty()){ Node node=que.top(); que.pop(); if(node.v==g) return d[g]; if(node.cost>d[node.v]) continue; for(auto& e : G[node.v]) { int cost=(e.com!=node.com); if(d[e.to]>d[node.v]+cost){ d[e.to]=d[node.v]+cost; que.emplace(e.to,d[e.to],e.com); } } } return -1; } int main() { std::cin>>n>>m; int p,q,c; for(int i=0;i<m;++i) { std::cin>>p>>q>>c; G[p-1].emplace_back(q-1,c); G[q-1].emplace_back(p-1,c); } ll ans=dijkstra(0,n-1); std::cout<<ans<<std::endl; return 0; }
a.cc:10:1: error: expected unqualified-id before 'constexpr' 10 | constexpr ll INF=(ll)1e9; | ^~~~~~~~~ a.cc: In function 'll dijkstra(int, int)': a.cc:51:14: error: 'INF' was not declared in this scope 51 | d[i]=INF; | ^~~
s701794584
p04003
C++
#include <iostream> #include <queue> #include <vector> #include <functional> using ll=long long int; constexpr int MAX_N=(int)1e5, constexpr ll INF=(ll)1e9; struct edge{ int to,com; edge()=default; edge(int _t,int _c) : to(_t),com(_c) {} }; struct Node{ int v,com; ll cost; Node()=default; Node(int _v,ll _cost,int _com) : v(_v),cost(_cost),com(_com) {} bool operator< (const Node& rhs) const{ return cost<rhs.cost; } bool operator> (const Node& rhs) const{ return cost>rhs.cost; } }; int n,m; std::vector<edge> G[MAX_N]; ll d[MAX_N]; ll dijkstra(int s,int g){ std::fill(d,d+n,INF); std::priority_queue<Node,std::vector<Node>,std::greater<Node>> que; que.emplace(s,d[s]=0,0); while(!que.empty()){ Node node=que.top(); que.pop(); if(node.v==g) return d[g]; if(node.cost>d[node.v]) continue; for(auto& e : G[node.v]) { int cost=(e.com!=node.com); if(d[e.to]>d[node.v]+cost){ d[e.to]=d[node.v]+cost; que.emplace(e.to,d[e.to],e.com); } } } return -1; } int main() { std::cin>>n>>m; int p,q,c; for(int i=0;i<m;++i) { std::cin>>p>>q>>c; G[p-1].emplace_back(q-1,c); G[q-1].emplace_back(p-1,c); } ll ans=dijkstra(0,n-1); std::cout<<ans<<std::endl; return 0; }
a.cc:10:1: error: expected unqualified-id before 'constexpr' 10 | constexpr ll INF=(ll)1e9; | ^~~~~~~~~ a.cc: In function 'll dijkstra(int, int)': a.cc:50:21: error: 'INF' was not declared in this scope 50 | std::fill(d,d+n,INF); | ^~~
s305450517
p04003
C++
#pragma GCC optimize "O3" #pragma GCC target "avx" #include <stdio.h> #include <string.h> #include <iostream> #include <string> #include <algorithm> #include <vector> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <functional> using namespace std; typedef long long ll; typedef vector<int> vint; typedef pair<int,int> pint; typedef vector<pint> vpint; #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i,n) for(int i=n-1;i>=(0);i--) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) #define all(v) (v).begin(),(v).end() #define eall(v) unique(all(v), v.end()) #define pb push_back #define mp make_pair #define fi first #define se second #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) const int MOD = 1e9 + 7; const int INF = 1e9; const ll INFF = 1e18; int N, M; vector<pair<int, int>> G[100010]; // G[i] := i->j color //dist[i<<32+j] := 頂点iへ路線 jでつくときのコストの最小値 unordered_map<uint64_t> dist; using PP = pair<int, pair<int, int>>; uint64_t func(uint64_t x, uint32_t y) { return (x << 32 + y); } void dijkstra(int start){ priority_queue<PP, vector<PP>, greater<PP>> que; // コスト 位置 路線 // dist[start][-1] = 0; dist[func(start, -1)] = 0; que.push(mp(0, mp(start, -1))); while(!que.empty()){ auto tm = que.top(); que.pop(); int cost = tm.fi, u = tm.se.fi, color = tm.se.se; if(dist[func(u, color)] < cost) continue; // これでTLE回避してください if(u == N - 1) break; for(auto tm : G[u]){ int v = tm.fi, nc = tm.se; // u->v nc int ncost = cost + ((nc == color) ? 0 : 1); if(dist.count(func(v, nc)) == 0 || dist[func(v, nc)] > ncost){ dist[func(v, nc)] = ncost; que.push(mp(ncost, mp(v, nc))); } } } } int main(void){ scanf("%d %d", &N, &M); rep(i, M){ int p, q, c; scanf("%d %d %d", &p, &q, &c); p--, q--; G[p].emplace_back(mp(q, c)), G[q].emplace_back(mp(p, c)); } dijkstra(0); int mi = INF; rep(i, 1000001){ if(dist.count(func(N - 1, i))) chmin(mi, dist[func(N - 1, i)]); } if(mi != INF) printf("%d\n", mi); else printf("-1\n"); return 0; }
a.cc:39:15: error: 'uint64_t' was not declared in this scope 39 | unordered_map<uint64_t> dist; | ^~~~~~~~ a.cc:14:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 13 | #include <functional> +++ |+#include <cstdint> 14 | using namespace std; a.cc:39:23: error: wrong number of template arguments (1, should be at least 2) 39 | unordered_map<uint64_t> dist; | ^ In file included from /usr/include/c++/14/unordered_map:41, from a.cc:11: /usr/include/c++/14/bits/unordered_map.h:109:11: note: provided for 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::unordered_map' 109 | class unordered_map | ^~~~~~~~~~~~~ a.cc:42:1: error: 'uint64_t' does not name a type 42 | uint64_t func(uint64_t x, uint32_t y) { | ^~~~~~~~ a.cc:42:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc: In function 'void dijkstra(int)': a.cc:48:10: error: 'func' was not declared in this scope 48 | dist[func(start, -1)] = 0; | ^~~~ a.cc:59:21: error: request for member 'count' in 'dist', which is of non-class type 'int' 59 | if(dist.count(func(v, nc)) == 0 || dist[func(v, nc)] > ncost){ | ^~~~~ a.cc: In function 'int main()': a.cc:78:17: error: request for member 'count' in 'dist', which is of non-class type 'int' 78 | if(dist.count(func(N - 1, i))) chmin(mi, dist[func(N - 1, i)]); | ^~~~~ a.cc:78:23: error: 'func' was not declared in this scope 78 | if(dist.count(func(N - 1, i))) chmin(mi, dist[func(N - 1, i)]); | ^~~~
s942964439
p04003
C++
#pragma GCC optimize "O3" #pragma GCC target "avx" #include <stdio.h> #include <string.h> #include <iostream> #include <string> #include <algorithm> #include <vector> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <functional> using namespace std; typedef long long ll; typedef vector<int> vint; typedef pair<int,int> pint; typedef vector<pint> vpint; #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i,n) for(int i=n-1;i>=(0);i--) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) #define all(v) (v).begin(),(v).end() #define eall(v) unique(all(v), v.end()) #define pb push_back #define mp make_pair #define fi first #define se second #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) const int MOD = 1e9 + 7; const int INF = 1e9; const ll INFF = 1e18; int N, M; vector<pair<int, int>> G[100010]; // G[i] := i->j color //dist[i<<32+j] := 頂点iへ路線 jでつくときのコストの最小値 unordered_map<uint64_t> dist; using PP = pair<int, pair<int, int>>; uint64_t func(uint64_t x, uint32_t y) { return (x << 32 + y); } void dijkstra(int start){ priority_queue<PP, vector<PP>, greater<PP>> que; // コスト 位置 路線 // dist[start][-1] = 0; dist[func(start, -1)] = 0; que.push(mp(0, mp(start, -1))); while(!que.empty()){ auto tm = que.top(); que.pop(); int cost = tm.fi, u = tm.se.fi, color = tm.se.se; if(dist[func(u, color)] < cost) continue; // これでTLE回避してください if(u == N - 1) break; for(auto tm : G[u]){ int v = tm.fi, nc = tm.se; // u->v nc int ncost = cost + ((nc == color) ? 0 : 1); if(dist.count(func(v, nc)) == 0 || dist[func(v, nc)] > ncost){ dist[func(v, nc)] = ncost; que.push(mp(ncost, mp(v, nc))); } } } } int main(void){ scanf("%d %d", &N, &M); rep(i, M){ int p, q, c; scanf("%d %d %d", &p, &q, &c); p--, q--; G[p].emplace_back(mp(q, c)), G[q].emplace_back(mp(p, c)); } dijkstra(0); int mi = INF; rep(i, 1000001){ if(dist.count(func(N - 1, i))) chmin(mi, dist[func(N - 1, i)]); } if(mi != INF) printf("%d\n", mi); else printf("-1\n"); return 0; }
a.cc:39:15: error: 'uint64_t' was not declared in this scope 39 | unordered_map<uint64_t> dist; | ^~~~~~~~ a.cc:14:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 13 | #include <functional> +++ |+#include <cstdint> 14 | using namespace std; a.cc:39:23: error: wrong number of template arguments (1, should be at least 2) 39 | unordered_map<uint64_t> dist; | ^ In file included from /usr/include/c++/14/unordered_map:41, from a.cc:11: /usr/include/c++/14/bits/unordered_map.h:109:11: note: provided for 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::unordered_map' 109 | class unordered_map | ^~~~~~~~~~~~~ a.cc:42:1: error: 'uint64_t' does not name a type 42 | uint64_t func(uint64_t x, uint32_t y) { | ^~~~~~~~ a.cc:42:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc: In function 'void dijkstra(int)': a.cc:48:10: error: 'func' was not declared in this scope 48 | dist[func(start, -1)] = 0; | ^~~~ a.cc:59:21: error: request for member 'count' in 'dist', which is of non-class type 'int' 59 | if(dist.count(func(v, nc)) == 0 || dist[func(v, nc)] > ncost){ | ^~~~~ a.cc: In function 'int main()': a.cc:78:17: error: request for member 'count' in 'dist', which is of non-class type 'int' 78 | if(dist.count(func(N - 1, i))) chmin(mi, dist[func(N - 1, i)]); | ^~~~~ a.cc:78:23: error: 'func' was not declared in this scope 78 | if(dist.count(func(N - 1, i))) chmin(mi, dist[func(N - 1, i)]); | ^~~~
s919216310
p04003
C++
// Header Files {{{ #include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <unordered_map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <numeric> using namespace std; // }}} // Alias {{{ template<typename T> using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >; typedef unsigned long long int ull; typedef long long int ll; #define rep(i,a,b) for (ll i=(a); i<(b); i++) typedef pair<int,int> PII; typedef pair<int,pair<int,int> > PIII; typedef pair<ll,ll> PLL; typedef vector<ll> VL; typedef vector<VL> MATRIX; typedef vector<char> VC; typedef vector<VC> CMATRIX; const int dy[] = {-1,0,1,0}; const int dx[] = {0,1,0,-1}; // }}} // Modulo {{{ ll mpow(ll x, ll y, ll m) { x %= m; ll result = 1; while (y > 0) { if (y & 1) result = (result * x) % m; x = (x * x) % m; y >>= 1; } return result; } // mod inverse 法mにおけるxの逆数 ull minverse(ull x, ull m) { return mpow(x, m-2, m); } // (1 + a + a^2 + a^3 ... + a^(n-1) ) % m ll modpowsum(ll a, ll n, ll m) { if(n==0){ return 0; } else if(n%2==1) { return (1+modpowsum(a,n-1,m)*a) % m; } else{ ll t = modpowsum(a,n/2,m); return (t+t*mpow(a,n/2,m)) % m; } } // s % m ll strmod (const string s, const ll m){ if(m==1) return 0; ll len=s.size(), res=0; ll t=1; // t: 10^i mod m rep(i,0,len){ int x = s[len-i-1] - '0'; res = (res + x * t) % m; t = (t*10) % m; } return res; } // }}} // Combination {{{ // 組合せ O(n) ll c (ll n, ll k, ll m) { static ll memo[1000][1000]; if (memo[n][k]!=0) return memo[n][k]; else if(n==k) return memo[n][k]=1; else if(k==0) return memo[n][k]=1; else return memo[n][k]=(c(n-1,k-1,m)+c(n-1,k,m))%m; } // 組合せ O(n+k) ll c2 (ll n, ll k, ll m){ if(n==0 && k==0) return 1; if(k>n) return 0; if(n<=0) return 0; if(n==k) return 1; ll res=1; for(ll x=n-k+1; x<=n; x++){ res = res*x; if(m!=-1) res %= m; } for(ll x=1; x<=k; x++) { if(m==-1) res = res/x; else res = (res*minverse(x,m)) %m; } return res; } // 組み合わせ O(n)の c3_init 実行後,O(1)のc3を実行 ll fact[400000]; ll rfact[400000]; void c3_init(ll m){ fact[0] = rfact[0] = 1; for(int i=1; i<400000; i++){ fact[i] = (fact[i-1]*i)%m; rfact[i] = minverse(fact[i],m); } } ll c3(ll n, ll k, ll m){ return (((fact[n] * rfact[k])%m) * rfact[n-k])%m; } // 重複組合せ O(n+k) ll hcomp(ll n, ll k, ll m) { return c(k+n-1,k,m); } // 重複組み合わせ O(n) ll hcomp2(ll n, ll k, ll m) { //return c(k+n-1,k,m); ll res=1; for (ll j=1; j<n; j++){ res = (res * (k+j)) % m; res = (res * minverse(j, m)) % m; } return res; } // 組み合わせ template<class BidirectionalIterator> bool next_combination ( BidirectionalIterator first1 , BidirectionalIterator last1 , BidirectionalIterator first2 , BidirectionalIterator last2 ) { if (( first1 == last1 ) || ( first2 == last2 )) { return false ; } BidirectionalIterator m1 = last1 ; BidirectionalIterator m2 = last2 ; --m2; while (--m1 != first1 && !(* m1 < *m2 )){ } bool result = (m1 == first1 ) && !(* first1 < *m2 ); if (! result ) { while ( first2 != m2 && !(* m1 < * first2 )) { ++ first2 ; } first1 = m1; std :: iter_swap (first1 , first2 ); ++ first1 ; ++ first2 ; } if (( first1 != last1 ) && ( first2 != last2 )) { m1 = last1 ; m2 = first2 ; while (( m1 != first1 ) && (m2 != last2 )) { std :: iter_swap (--m1 , m2 ); ++ m2; } std :: reverse (first1 , m1 ); std :: reverse (first1 , last1 ); std :: reverse (m2 , last2 ); std :: reverse (first2 , last2 ); } return ! result ; } template < class BidirectionalIterator > bool next_combination ( BidirectionalIterator first , BidirectionalIterator middle , BidirectionalIterator last ) { return next_combination (first , middle , middle , last ); } // }}} // Union Find {{{ class UnionFind { public: int n; vector<int> par; vector<int> num; UnionFind(int n){ // [0 n)のunion find this->n = n; this->par.resize(n); this->num.resize(n,1); for(int i=0;i<n;i++){ this->par[i] = i; } } int root(int i) { if(par[i]==i) return i; else return par[i]=root(par[i]); } bool same(int i, int j){ return root(i)==root(j); } void unite(int i,int j){ int t = root(i); int k = root(j); if(t==k) return; par[t] = k; num[k] += num[t]; } int size(int i){ return num[root(i)]; } }; // }}} // Segment Tree {{{ template <typename T> class SegTree { private: int _n; T _init_val; vector<T> _data; function<T(T,T)> _f; T _query(int a, int b, int k, int l, int r) { // [a b)と[l r]が交差しない if (r<=a || b <=l) return _init_val; // [a b)が[l r]を含む if (a<=l && r<=b) return _data[k]; T vl = _query(a,b, k*2+1, l, (l+r)/2); T vr = _query(a,b, k*2+2, (l+r)/2, r); return _f(vl,vr); } public: SegTree (int n, T init_val, function<T(T, T)> f) { _init_val = init_val; _n = 1; _f = f; while(_n < n) _n *= 2; _data.resize(2*_n, init_val); } T get (int k) { return _data[k + _n -1]; } void update(int k, T a) { k += _n-1; _data[k] = a; while(k>0){ k = (k-1)/2; _data[k] = _f( _data[k*2+1], _data[k*2+2] ); } } // [a b)の範囲でfを適用 T query(int a,int b) { return _query(a,b,0,0,_n); } // 先頭からチェックし,はじめてxを満たしたインデックス int lower_bound (T x) { return _lower_bound(x,0); } int _lower_bound (T x, int k){ if (k >= _n-1){ return k- (_n-1); // 葉 } else if (_data[k] < x) { return _n; // 該当なし } else if (x <= _data[k*2+1]){ return _lower_bound(x,k*2+1); } else { return _lower_bound(x- _data[k*2+1] ,k*2+2); } } }; // }}} // Block {{{ // 範囲 1-3, 5-7, 10-199 // ↓ 2-6を追加 // 1-7, 10-199 class Block { public: vector< pair<int,int> > block; void add(int l, int r) { // ブロックを生成 auto it = lower_bound(begin(this->block),end(this->block),make_pair(l,r)); auto jt = it; jt--; //if(it!=block.end()){ // cout<<"it: ("<<it->first<<"-"<<it->second<<endl; //} // 1.後半のブロックとくっつける if(it != block.end() && r >= it->first){ it->first = min(l, it->first); it->second = max(r, it->second); // その後前半のブロックとくっつける auto jt = it; jt--; if(it!=block.begin() && jt->second >= it->first){ it->first = min(it->first, jt->first); it->second = max(it->second, jt->second); this->block.erase(jt); } } // 2.前半のブロックとくっつける else if(it!=block.begin() && jt->second >= l){ jt->first = min(jt->first, l); jt->second = max(jt->second, r); } // 3.くっつかない else { block.insert(it,make_pair(l,r)); } } }; // }}} // Bit {{{ long long bit_count(unsigned long long i) { i = i - ((i >> 1) & 0x5555555555555555); i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333); return (((i + (i >> 4)) & 0x0F0F0F0F0F0F0F0F) * 0x0101010101010101) >> 56; } // }}} // String {{{ class SuffixArray { public: string s; // 対象文字列 vector<int> sa; // suffix array本体 i -> sa[i] vector<int> rsa; // suffix array本体 sa[i] -> i vector<int> lcp; // Longest Common Prefix Array,高さ配列 SegTree<int> st_lcp; // lcpのセグメントツリー // O(n log n) SuffixArray(string s): s(s), st_lcp(s.size()+1,1<<29,[](int a,int b){return min(a,b);}) { sa = construct_sa(); lcp = construct_lcp(); // saの逆も作る rsa = vector<int>(s.size()+1,0); for(int i=0;i<sa.size();i++){ rsa[sa[i]]=i; } // セグメントツリーの初期化 O(n log n) for(int i=0;i<lcp.size();i++){ st_lcp.update(i,lcp[i]); } } // (rank[i],rank[i+k])と(rank[j], rank[j+k])を比較 bool compare_sa(int i, int j, int k, int n, vector<int> &rank){ if(rank[i] != rank[j]){ return rank[i] < rank[j]; }else{ int ri = i+k<=n ? rank[i+k] : -1; int rj = j+k<=n ? rank[j+k] : -1; return ri<rj; } } // O(n) vector<int> construct_sa(){ int n = s.size(); vector<int> res(n+1,0); vector<int> rank(n+1,0); vector<int> tmp(n+1,0); // 最初は,文字コードをランクにする for (int i=0; i<=n; i++){ res[i] = i; rank[res[i]] = i<n ? s[i] : -1; } // k文字についてソートされているところから,2k文字でソートする for(int k=1;k<=n;k*=2){ auto f= [&](int i, int j){ return this->compare_sa(i,j,k,n,rank);}; sort(begin(res),end(res),f); tmp[res[0]] = 0; for(int i=1;i<=n;i++){ tmp[res[i]] = tmp[res[i-1]] + (f(res[i-1],res[i])?1:0); } rank=tmp; } return res; } // O(n) // 高さ配列lcpを作成 vector<int> construct_lcp(){ int n = s.size(); vector<int> rank(n+1,0); vector<int> res(n+1,0); for(int i=0;i<=n;i++) rank[sa[i]]=i; int h = 0; res[0]=0; for(int i=0;i<n;i++){ int j = sa[rank[i]-1]; if(h>0) h--; for(; j+h<n && i+h<n; h++){ if(s[j+h] != s[i+h]) break; } res[rank[i]-1]=h; } return res; } void dump() { int n= s.size(); cout<<"# SuffixArray dump"<<endl; cout<<"s = "<<s<<endl; cout<<"----------------------"<<endl; cout<<" i sa[i] lcp[i] s[sa[i]...]"<<endl; for(int i=0;i<=n;i++){ printf("%2d%6d%7d %s\n",i,sa[i],lcp[i],s.substr(sa[i]).c_str()); } } // O(1) // 部分文字列s[i...]のランクを返す int getRank(int i){ return rsa[i]; } // O(log n) // suffix array を使って部分文字列patのs内の位置を検索 // 見つかれなければ-1を返す int find(const string &pat){ int a=0, b=s.size(); while(b-a>1){ int c = (a+b)/2; if(s.compare(sa[c], pat.size(), pat) < 0) a = c; else b = c; } if(s.compare(sa[b],pat.size(),pat)==0){ return sa[b]; }else{ return -1; } } // 文字列sの s[i..] と s[j..] の先頭共通文字数を返す // O(log n) int prefixCommonLength(int i, int j){ if(i==j) return s.size()-i; i = rsa[i]; j = rsa[j]; return st_lcp.query(min(i,j), max(i,j)); } }; // 最長部分文字列 ll LCS(string s, string t){ ll s_len = s.size(); ll t_len = t.size(); // テーブルの初期化 ll table[s_len+1][t_len+1]; rep(i,0,s_len+1) table[i][0]=0; rep(j,0,t_len+1) table[0][j]=0; rep(i,0,s_len) rep(j,0,t_len) if(s[i]==t[j]){ table[i+1][j+1] = max(max(table[i+1][j], table[i][j+1]), table[i][j]+1); }else{ table[i+1][j+1] = max(max(table[i+1][j], table[i][j+1]), table[i][j]); } return table[s_len][t_len]; } // }}} // ハッシュ // unordered_mapのKeyにPLLを使う template<> class hash<PLL> { public: size_t operator()(const PLL &x) const { return ((x.first) << 32) | x.second; } }; int N,M; const ll INF=1L<<59; unordered_map<PLL, ll> dis; // {station, company} -> cost unordered_map<PLL, vector<pair<PLL,ll>>> edges; signed main() { cin>>N>>M; for (int i=0; i<M; i++) { ll p,q,c; cin>>p>>q>>c; p--; q--; edges[ make_pair(p,c) ].emplace_back( make_pair(q,c), 0); edges[ make_pair(q,c) ].emplace_back( make_pair(p,c), 0); // c=0 は改札の外とする // 改札に入るのは自由 edges[ make_pair(p,0) ].emplace_back( make_pair(p,c), 0); edges[ make_pair(q,0) ].emplace_back( make_pair(q,c), 0); // 改札を出るのはコスト1 edges[ make_pair(p,c) ].emplace_back( make_pair(p,0), 1); edges[ make_pair(q,c) ].emplace_back( make_pair(q,0), 1); } priority_queue< pair<ll,PLL>, vector<pair<ll,PLL>>, greater<pair<ll,PLL>>> q; q.emplace(0, make_pair(0, 0)); while (!q.empty()) { PLL v; ll c; tie(c, v) = q.top(); q.pop(); if ( dis.find(v) != dis.end() && c >= dis[v] ) { continue; } dis[v] = c; //cout << v.first << "," << v.second << "->" << c << endl; for (auto e: edges[v]) { PLL nv = e.first; ll nc = c + e.second; q.emplace(nc, nv); } } if (dis.find(make_pair(N-1,0)) != dis.end()) { cout << dis[make_pair(N-1,0)] << endl; } else { cout << -1 << endl; } return 0; }
a.cc:508:7: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive] 508 | class hash<PLL> { | ^~~~~~~~~
s276035787
p04003
C++
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(ll i=0; i<(ll)(n); i++) #define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++) #define pb push_back #define INF 1000000007LL #define all(a) (a).begin(),(a).end() typedef long long ll; typedef pair<ll, pair<int,int> > p; int dy[4]={-1,1,0,0}; int dx[4]={0,0,1,-1}; #define MAX_V 100010 set<int> sta[MAX_V]; struct edge {pair<int,int> to;int cost;}; int V=0; unordered_map<pair<int,int>, vector<p> > G; unordered_map<pair<int,int>, int> d; void dijkstra(pair<int,int> s){ priority_queue<p,vector<p>, greater<p> > que; d[s]=0; que.push(p(0,s)); while(!que.empty()){ p pii = que.top(); que.pop(); pair<int,int> v = pii.second; if(d.find(v) != d.end() && d[v] < pii.first) continue; // 普通のエッジ REP(i,G[v].size()){ edge e = {G[v][i].second,G[v][i].first}; if(d.find(e.to) == d.end() || d[e.to] > d[v] + e.cost){ d[e.to] = d[v] + e.cost; que.push(p(d[e.to],e.to)); } } // 同じ駅間のエッジ for (auto x:sta[v.first]) { if(x == v.second) continue; int cost = v.first==0 ? 0 : 1; pair<int,int> to = pair<int,int>(v.first,x); if(d.find(to) == d.end() || d[to] > d[v] + cost){ d[to] = d[v] + cost; que.push(p(d[to],to)); } } } } #define MAX_M 100010 int N,M; int pi[MAX_M],qi[MAX_M],ci[MAX_M]; int main(){ ios::sync_with_stdio(false); cin >> N >> M; REP(i,M) { cin >> pi[i] >> qi[i] >> ci[i]; pi[i]--; qi[i]--; G[pair<int,int>(pi[i],ci[i])].pb(p(0,pair<int,int>(qi[i],ci[i]))); sta[pi[i]].insert(ci[i]); sta[qi[i]].insert(ci[i]); } int stline = 0; for(auto x:sta[0]) { stline = x; break; } dijkstra(pair<int,int>(0,stline)); int ans = INF; for(auto x:sta[N-1]) { pair<int,int> to = pair<int, int>(N-1,x); if (d.find(to) != d.end()) continue; ans = min(ans,d[to]); } cout << ans << endl; return 0; }
a.cc:21:42: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = std::vector<std::pair<long long int, std::pair<int, int> > >; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > > >]' 21 | unordered_map<pair<int,int>, vector<p> > G; | ^ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = std::vector<std::pair<long long int, std::pair<int, int> > >; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > > >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > >; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > >; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > >, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, std::vector<std::pair<long long int, std::pair<int, int> > > >, std
s258391321
p04003
C++
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(ll i=0; i<(ll)(n); i++) #define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++) #define pb push_back #define INF 1000000007LL #define all(a) (a).begin(),(a).end() typedef long long ll; typedef pair<ll, pair<int,int> > p; int dy[4]={-1,1,0,0}; int dx[4]={0,0,1,-1}; #define MAX_V 100010 set<int> sta[MAX_V]; struct edge {pair<int,int> to;int cost;}; int V=0; unordered_map<pair<int,int>, vector<edge> > G; unordered_map<pair<int,int>, int> d; void dijkstra(pair<int,int> s){ priority_queue<p,vector<p>, greater<p> > que; d[s]=0; que.push(p(0,s)); while(!que.empty()){ p pii = que.top(); que.pop(); pair<int,int> v = pii.second; if(d.find(v) != d.end() && d[v] < pii.first) continue; // 普通のエッジ REP(i,G[v].size()){ edge e = G[v][i]; if(d.find(e.to) == d.end() || d[e.to] > d[v] + e.cost){ d[e.to] = d[v] + e.cost; que.push(p(d[e.to],e.to)); } } // 同じ駅間のエッジ for (auto x:sta[v.first]) { if(x == v.second) continue; int cost = v.first==0 ? 0 : 1; pair<int,int> to = pair<int,int>(v.first,x); if(d.find(to) == d.end() || d[to] > d[v] + cost){ d[to] = d[v] + cost; que.push(p(d[to],to)); } } } } #define MAX_M 100010 int N,M; int pi[MAX_M],qi[MAX_M],ci[MAX_M]; int main(){ ios::sync_with_stdio(false); cin >> N >> M; REP(i,M) { cin >> pi[i] >> qi[i] >> ci[i]; pi[i]--; qi[i]--; G[pair<int,int>(pi[i],ci[i])].pb(edge({pair<int,int>(qi[i],ci[i]), 0})); sta[pi[i]].insert(ci[i]); sta[qi[i]].insert(ci[i]); } int stline = 0; for(auto x:sta[0]) { stline = x; break; } dijkstra(pair<int,int>(0,stline)); int ans = INF; for(auto x:sta[N-1]) { pair<int,int> to = pair<int, int>(N-1,x); if (d.find(to) != d.end()) continue; ans = min(ans,d[to]); } cout << ans << endl; return 0; }
a.cc:21:45: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = std::vector<edge>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<edge> > >]' 21 | unordered_map<pair<int,int>, vector<edge> > G; | ^ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = std::vector<edge>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<edge> > >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<edge> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<edge> > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<edge> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<edge> > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<edge> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<edge> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<edge> >; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<edge> >; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, std::vector<edge> >, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, std::vector<edge> >, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considere
s322344932
p04003
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <map> #define MAX_V 600000 #define LL long long using namespace std; const int INF = 1000000000; struct edge { int to, cost; }; typedef pair<int, int> P; int V; vector<edge> G[MAX_V]; int d[MAX_V]; void dijkstra(int s){ priority_queue<P, vector<P>, greater<P> > que; fill(d,d+V, INF); d[s] = 0; que.push(P(0,s)); while(!que.empty()){ P p = que.top(); que.pop(); int v = p.second; if(d[v]<p.first) continue; for(int i=0;i<G[v].size();i++){ edge e = G[v][i]; if(d[e.to]>d[v]+e.cost){ d[e.to] = d[v]+e.cost; que.push(P(d[e.to],e.to)); } } } } map<P, int> m; int cnt2 = 0; int N, M; void f(P x, P y, int c){ edge *e = new edge; e->to = m[y]; e->cost = m[c]; G[m[x]].push_back(*e); } int main() { cin >> N >> M; int cnt1 = 1; for(int i=0;i<N;i++){ m[P(i,-1)]= cnt1++; } for(int i=0;i<M;i++){ int a,b,c; scanf(" %d %d %d", &a, &b, &c); a--; b--; P eg0 = P(a,c), eg1 = P(b,c); P ng0 = P(a,-1), ng1 = P(b,-1); if(m[eg0]==0){ m[eg0] = cnt1; cnt1++; f(eg0,ng0,0); f(ng0,eg0,1); } if(m[eg1]==0){ m[eg1] = cnt1; cnt1++; f(eg1,ng1,0); f(ng1,eg1,1); } f(eg0,eg1,0); f(eg1,eg0,0); } int end = m[P(N-1,-1)]; V = cnt1; dijkstra(1); cout << (d[end]==INF?-1:d[end]) << endl; return 0; }
a.cc: In function 'void f(P, P, int)': a.cc:45:30: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'int') 45 | e->to = m[y]; e->cost = m[c]; | ^ In file included from /usr/include/c++/14/map:63, from a.cc:6: /usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]' 504 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'int' to 'const std::map<std::pair<int, int>, int>::key_type&' {aka 'const std::pair<int, int>&'} 504 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]' 524 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'} 524 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~
s828932388
p04003
C++
using System; using System.Collections.Generic; using System.Linq; struct Z2 { public int x, y; public Z2(int x, int y){ this.x = x; this.y = y; } } struct Z3 { public int x; public Z2 z; public Z3(int x, Z2 z){ this.x = x; this.z = z; } } public class A { int N,M; Dictionary<Z2,List<Z2>> edges; public A(){ edges = new Dictionary<Z2,List<Z2>>(); } string[] Rs(){ return Console.ReadLine().Split(' '); } public void run(){ string[] str = Rs(); N = int.Parse(str[0]); M = int.Parse(str[1]); for(int i=0;i<N;i++){ edges.Add(new Z2(i,-1), new List<Z2>()); } Action<Z2,Z2> f = (p1,p2) => { if(edges.ContainsKey(p1)){ edges[p1].Add(p2); } else { var l = new List<Z2>(); l.Add(p2); edges.Add( p1, l); } Z2 ne = new Z2(p1.x, -1); edges[p1].Add(ne); edges[ne].Add(new Z2(p2.x,-1)); }; for(int i=0;i<M;i++){ int[] inp = Rs().Select( x => int.Parse(x)-1 ).ToArray(); Z2 e0 = new Z2(inp[0], inp[2]), e1 = new Z2(inp[1], inp[2]); f(e0,e1); f(e1,e0); } Dictionary<Z2, int> dis = new Dictionary<Z2,int>(); LinkedList<Z3> que = new LinkedList<Z3>(); que.AddLast(new Z3(0, new Z2(0,-1)) ); dis.Add( new Z2(0, -1), 0); Z2 end = new Z2(N-1,-1); while(que.Count!=0){ Z3 n = que.First(); que.RemoveFirst(); Z2 nz = n.z; if(dis.ContainsKey(end)){ Console.WriteLine(dis[end]); return; } if(n.x > dis[nz]) continue; foreach(Z2 e in edges[nz]){ if(nz.y==-1){ int nv = dis[nz] + 1; if(!dis.ContainsKey(e)){ dis.Add(e, nv); que.AddLast(new Z3(nv, e)); } else if(nv < dis[e]){ dis[e] = nv; que.AddLast(new Z3(nv, e)); } } else { if(!dis.ContainsKey(e)){ dis.Add(e, dis[nz]); que.AddFirst(new Z3(dis[nz], e)); } else if(dis[nz] < dis[e]){ dis[e] = dis[nz]; que.AddFirst(new Z3(dis[nz], e)); } } } } Console.WriteLine("-1"); } } public class Program { static void Main(string[] args){ A a = new A(); a.run(); } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System.Linq; | ^~~~~~ a.cc:8:15: error: expected ':' before 'int' 8 | public int x, y; | ^~~~ | : a.cc:9:15: error: expected ':' before 'Z2' 9 | public Z2(int x, int y){ | ^~~ | : a.cc:12:2: error: expected ';' after struct definition 12 | } | ^ | ; a.cc: In constructor 'Z2::Z2(int, int)': a.cc:10:22: error: request for member 'x' in '(Z2*)this', which is of pointer type 'Z2*' (maybe you meant to use '->' ?) 10 | this.x = x; this.y = y; | ^ a.cc:10:34: error: request for member 'y' in '(Z2*)this', which is of pointer type 'Z2*' (maybe you meant to use '->' ?) 10 | this.x = x; this.y = y; | ^ a.cc: At global scope: a.cc:15:15: error: expected ':' before 'int' 15 | public int x; | ^~~~ | : a.cc:16:15: error: expected ':' before 'Z2' 16 | public Z2 z; | ^~~ | : a.cc:17:15: error: expected ':' before 'Z3' 17 | public Z3(int x, Z2 z){ | ^~~ | : a.cc:20:2: error: expected ';' after struct definition 20 | } | ^ | ; a.cc: In constructor 'Z3::Z3(int, Z2)': a.cc:17:31: error: no matching function for call to 'Z2::Z2()' 17 | public Z3(int x, Z2 z){ | ^ a.cc:9:16: note: candidate: 'Z2::Z2(int, int)' 9 | public Z2(int x, int y){ | ^~ a.cc:9:16: note: candidate expects 2 arguments, 0 provided a.cc:7:8: note: candidate: 'constexpr Z2::Z2(const Z2&)' 7 | struct Z2 { | ^~ a.cc:7:8: note: candidate expects 1 argument, 0 provided a.cc:7:8: note: candidate: 'constexpr Z2::Z2(Z2&&)' a.cc:7:8: note: candidate expects 1 argument, 0 provided a.cc:18:22: error: request for member 'x' in '(Z3*)this', which is of pointer type 'Z3*' (maybe you meant to use '->' ?) 18 | this.x = x; this.z = z; | ^ a.cc:18:34: error: request for member 'z' in '(Z3*)this', which is of pointer type 'Z3*' (maybe you meant to use '->' ?) 18 | this.x = x; this.z = z; | ^ a.cc: At global scope: a.cc:22:1: error: expected unqualified-id before 'public' 22 | public class A { | ^~~~~~ a.cc:100:1: error: expected unqualified-id before 'public' 100 | public class Program { | ^~~~~~
s853204528
p04003
C++
using System; using System.Collections.Generic; using System.Linq;   struct Z2 { public int x, y; public Z2(int x, int y){ this.x = x; this.y = y; } } struct Z3 { public int x, y, z; public Z3(int x, int y, int z){ this.x = x; this.y = y; this.z = z; } }   public class A { int MAX_N = 100008; int N,M; List<Z2>[] edges; public A(){ edges = new List<Z2>[MAX_N]; for(int i=0;i<MAX_N;i++) edges[i] = new List<Z2>(); } string[] Rs(){ return Console.ReadLine().Split(' '); } public void run(){ string[] str = Rs(); N = int.Parse(str[0]); M = int.Parse(str[1]); for(int i=0;i<M;i++){ int[] inp = Rs().Select( x => int.Parse(x)-1 ).ToArray(); edges[ inp[0] ].Add( new Z2(inp[1],inp[2]) ); edges[ inp[1] ].Add( new Z2(inp[0],inp[2]) ); } edges[N-1].Add(new Z2(N-1,-1)); Dictionary<Z2, int> dis = new Dictionary<Z2,int>(); LinkedList<Z3> que = new LinkedList<Z3>(); que.AddLast(new Z3(0, -1, 0) ); dis.Add(new Z2(0,-1), 0); Z2 end = new Z2(N-1,-1); while(que.Count != 0){ Z3 n = que.First(); que.RemoveFirst(); Z2 n2 = new Z2(n.x, n.y); if(dis.ContainsKey(end)){ Console.WriteLine(dis[end]-1); return; } if(dis[n2] < n.z) continue; foreach(Z2 e in edges[n.x]){ Z3 e3 = new Z3(e.x, e.y, dis[n2]); if(e.y == n.y){ if(!dis.ContainsKey(e)){ dis.Add(e, dis[n2]); que.AddFirst(e3); } else if(dis[n2] < dis[e]){ dis[e] = dis[n2]; que.AddLast(e3); } } else { e3.z += 1; if(!dis.ContainsKey(e)){ dis.Add(e, e3.z); que.AddLast(e3); } else if(dis[n2]+1 < dis[e]){ dis[e] = e3.z; que.AddLast(e3); } } } } Console.WriteLine("-1"); } }   public class Program { static void Main(string[] args){ A a = new A(); a.run(); } }
a.cc:4:1: error: extended character   is not valid in an identifier 4 |   | ^ a.cc:17:1: error: extended character   is not valid in an identifier 17 |   | ^ a.cc:86:1: error: extended character   is not valid in an identifier 86 |   | ^ a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System.Linq; | ^~~~~~ a.cc:4:1: error: '\U000000a0' does not name a type 4 |   | ^ a.cc:12:15: error: expected ':' before 'int' 12 | public int x, y, z; | ^~~~ | : a.cc:13:15: error: expected ':' before 'Z3' 13 | public Z3(int x, int y, int z){ | ^~~ | : a.cc: In constructor 'Z3::Z3(int, int, int)': a.cc:14:22: error: request for member 'x' in '(Z3*)this', which is of pointer type 'Z3*' (maybe you meant to use '->' ?) 14 | this.x = x; this.y = y; this.z = z; | ^ a.cc:14:34: error: request for member 'y' in '(Z3*)this', which is of pointer type 'Z3*' (maybe you meant to use '->' ?) 14 | this.x = x; this.y = y; this.z = z; | ^ a.cc:14:46: error: request for member 'z' in '(Z3*)this', which is of pointer type 'Z3*' (maybe you meant to use '->' ?) 14 | this.x = x; this.y = y; this.z = z; | ^ a.cc: At global scope: a.cc:18:1: error: expected initializer before 'public' 18 | public class A { | ^~~~~~ a.cc:86:1: error: '\U000000a0' does not name a type 86 |   | ^
s609168465
p04003
C++
using System; using System.Collections.Generic; using System.Linq;  struct Z2 { public int x, y; public Z2(int x, int y){ this.x = x; this.y = y; } }   public class A { int MAX_N = 100008; int MAX_M = 200008; int INF = 2000000; int N,M; List<Z2>[] edges; public A(){ edges = new List<Z2>[MAX_N]; for(int i=0;i<MAX_N;i++) edges[i] = new List<Z2>(); } string[] Rs(){ return Console.ReadLine().Split(' '); } public void run(){ string[] str = Rs(); N = int.Parse(str[0]); M = int.Parse(str[1]); for(int i=0;i<M;i++){ int[] inp = Rs().Select( x => int.Parse(x)-1 ).ToArray(); edges[ inp[0] ].Add( new Z2(inp[1],inp[2]) ); edges[ inp[1] ].Add( new Z2(inp[0],inp[2]) ); } Dictionary<long, long> dis = new Dictionary<long,long>(3*MAX_M); Queue<Z2> que = new Queue<Z2>(); que.Enqueue(new Z2(0, -1) ); // (position, company) dis.Add(-1, 0); while(que.Count != 0){ Z2 n = que.Dequeue(); if(n.x == N-1){ Console.WriteLine(dis[n.x*INF+n.y]); return; } Queue<int> que2 = new Queue<int>(); que2.Enqueue(n.x); while(que2.Count!=0){ int now = que2.Dequeue(); foreach(Z2 e in edges[now]){ Z2 cd = new Z2(now, n.y); if(e.x==N-1 && e.y==n.y){ Console.WriteLine(dis[n.x*INF+n.y]); return; } if(e.y == n.y){ if( !dis.ContainsKey(e.x*INF+e.y) ){ que2.Enqueue(e.x); dis.Add(e.x*INF+e.y, dis[cd.x*INF+cd.y]); } else if(dis[e.x*INF+e.y] > dis[cd.x*INF+cd.y]){ que2.Enqueue(e.x); dis[e.x*INF+e.y] = dis[cd.x*INF+cd.y]; } } else { if( !dis.ContainsKey(e.x*INF+e.y) ){ que.Enqueue(e); dis.Add(e.x*INF+e.y, dis[n.x*INF+n.y]+1); } else if( dis[e.x*INF+e.y] > dis[n.x*INF+n.y]+1){ que.Enqueue(e); dis[e.x*INF+e.y] = dis[n.x*INF+n.y]+1; } } } } } Console.WriteLine("-1"); } }   public class Program { static void Main(string[] args){ A a = new A(); a.run(); } }
a.cc:4:1: error: extended character   is not valid in an identifier 4 |  struct Z2 { | ^ a.cc:10:1: error: extended character   is not valid in an identifier 10 |   | ^ a.cc:85:1: error: extended character   is not valid in an identifier 85 |   | ^ a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System.Linq; | ^~~~~~ a.cc:4:1: error: '\U000000a0struct' does not name a type; did you mean 'struct'? 4 |  struct Z2 { | ^~~~~~~ | struct a.cc:10:1: error: '\U000000a0' does not name a type 10 |   | ^ a.cc:85:1: error: '\U000000a0' does not name a type 85 |   | ^
s190658966
p04003
C++
#include <iostream> #include <vector> #include <set> #include <algorithm> #include <map> #include <queue> #define mp make_pair #define pb push_back #define ppb pop_back #define fi first #define se second using namespace std; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef long long ll; typedef pair<ll, ll> pl; typedef vector<ll> vl; typedef vector<pl> vpl; typedef vector<vl> vvl; typedef vector<bool> vb; typedef vector<vb> vvb; #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define fors(i, n, s) for (int i = 0; i < (int)(n); i += s) #define forn1(i, n) for (int i = 1; i <= (int)(n); ++i) #define forn11(i, n) for (int i = 1; i < (int)(n); ++i) #define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i) #define prOk(ok) cout << ((ok) ? "Yes" : "No") #define in insert #define rem remove #define linf ((ll) 1e9) #define inf ((int) 1e5) int main() { cin.tie(0); ios::sync_with_stdio(false); ll numSta, numLine; cin >> numSta >> numLine; static vpl g[linf]; //graph as connectivity list map<pl, ll> ids; ll lastId = numSta; forn(i, numLine) { int a,b, com; cin >> a >> b >> com; a--; b--; com--; //zero based ll ida, idb; if(ids.count(mp(a, com)) == 0) { ids[mp(a, com)] = ida = lastId++; g[a].pb(mp(ida, 1)); g[ida].pb(mp(a, 0)); } else ida = ids[mp(a, com)]; if(ids.count(mp(b, com)) == 0) { ids[mp(b, com)] = idb = lastId++; g[b].pb(mp(idb, 1)); g[idb].pb(mp(b, 0)); } else idb = ids[mp(b, com)]; g[ida].pb(mp(idb, 0)); g[idb].pb(mp(ida, 0)); } //SPFA for shortest path - https://en.wikipedia.org/wiki/Shortest_Path_Faster_Algorithm vl dist(linf, linf); dist[0] = 0; queue<ll> q; set<ll> inQ; q.push(0); inQ.insert(0); while(!q.empty()) { ll u = q.front(); q.pop(); inQ.erase(u); for(auto e : g[u]) { ll alt = dist[u] + e.second; if(alt < dist[e.first]) { dist[e.first] = alt; if(inQ.count(e.first) == 0) { q.push(e.first); inQ.insert(e.first); } } } } if(dist[numSta-1] == linf) cout << -1; else cout << dist[numSta-1]; return 0; }
/tmp/ccgQGI9M.o: in function `main': a.cc:(.text+0x9f): relocation truncated to fit: R_X86_64_PC32 against `.bss' a.cc:(.text+0xaf): relocation truncated to fit: R_X86_64_PC32 against `.bss' a.cc:(.text+0x10b): relocation truncated to fit: R_X86_64_PC32 against `.bss' collect2: error: ld returned 1 exit status
s970652921
p04003
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; int nextInt() { int x; scanf("%d", &x); return x; } const int MAX_N = 100000 + 10; map<P, vector<int> > g; vector<P> es[MAX_N]; struct State { int pos; int pc; int cost; State(int a, int b, int c) : pos(a), pc(b), cost(c) {} }; int main() { int N = nextInt(); int M = nextInt(); vector<L> vl; for (int i = 0; i < M; i++) { int p = nextInt() - 1; int q = nextInt() - 1; int c = nextInt(); es[p].emplace_back(q, c); es[q].emplace_back(p, c); g[P(p,c)].push_back(q); g[P(q,c)].push_back(p); } int ans = -1; map<P, int> memo; // 0なら存在しないノード、最小値は 1 deque<State> pq; pq.emplace_back(0, 0, 1); // 今いる駅, 最後に使った会社, コスト memo[P(0,0)] = 1; while (!pq.empty()) { const State state = pq.front(); pq.pop_front(); const int cost = memo[P(state.pos, state.pc)]; if (state.cost != cost) continue; const int cost = state.cost; if (state.pos == N - 1 && state.pc == -1) { ans = cost - 1; break; } if (state.pc == -1) { for (P e : es[state.pos]) { int next_cost = cost + 1; auto f = memo.find(e); if (f == memo.end() || f->second > next_cost) { memo[e] = next_cost; pq.emplace_back(e.first, e.second, next_cost); } } } else { for (int next_pos : g[P(state.pos, state.pc)]) { P e(next_pos, state.pc); int next_cost = cost; auto f = memo.find(e); if (f == memo.end() || f->second > next_cost) { memo[e] = next_cost; pq.emplace_front(e.first, e.second, next_cost); } } { int next_pos = state.pos; int next_pc = -1; P e(next_pos, next_pc); int next_cost = cost ; auto f = memo.find(e); if (f == memo.end() || f->second > next_cost) { memo[e] = next_cost; pq.emplace_front(e.first, e.second, next_cost); } } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:26:10: error: 'L' was not declared in this scope 26 | vector<L> vl; | ^ a.cc:26:11: error: template argument 1 is invalid 26 | vector<L> vl; | ^ a.cc:26:11: error: template argument 2 is invalid a.cc:47:15: error: redeclaration of 'const int cost' 47 | const int cost = state.cost; | ^~~~ a.cc:45:15: note: 'const int cost' previously declared here 45 | const int cost = memo[P(state.pos, state.pc)]; | ^~~~
s491730212
p04003
C++
#include <iostream> #include <vector> #include <set> #include <unordered_set> #include <iterator> #include <map> #include <unordered_map> #include <queue> using namespace std; #define Inf 1073741789 int N, M, V; int* us, vs, xs; unordered_set<int> dead; // vector<vector<int> > es; vector<int>* es; // const int Inf = 1073741789; int* dijkstra(int from) { auto d = new int[V]; // vector<int> d(V); // for (int i = 0; i < V; i++) d.push_back(Inf); for (int i = 0; i < V; i++) d[i] = Inf; priority_queue<pair<int, int> > queue; d[from] = 0; queue.emplace(from, 0); while (queue.size() > 0) { auto p = queue.top(); queue.pop(); int u = p.first, tmp = d[u] + dead.count(u); if (d[u] < -p.second) continue; for (auto v : es[u]) if (d[v] > tmp) queue.emplace(v, -(d[v] = tmp)); } return d; } int main() { cin >> N >> M; //vector<set<int> > cs(N); auto cs = new set<int>[N]; for (int i = 0; i < N; i++) cs[i].insert(-1); // for (int i = 0; i < N; i++) // { // cs.push_back(set<int>()); // cs[i].insert(-1); // } us = new int[M]; vs = new int[M]; xs = new int[M]; for (int i = 0; i < M; i++) { int a, b, c; cin >> a >> b >> c; us[i] = --a; vs[i] = --b; xs[i] = --c; cs[a].insert(c); cs[b].insert(c); } // vector<int> sep; auto sep = new int[N + 1]; // sep.push_back(0); sep[0] = 0; for (int i = 0; i < N; i++) sep[i + 1] = sep[i] + cs[i].size(); // for (int i = 0; i < N; i++) sep.push_back(sep[i] + cs[i].size()); dead.insert(sep, sep + N + 1); // dead.insert(sep.begin(), sep.end()); V = sep[N]; // vector<map<int, int> > index; auto index = new map<int, int>[N]; for (int i = 0, j = 0; i < N; i++) for (auto c : cs[i]) index[i].emplace(c, j++); // for (int i = 0, j = 0; i < N; i++) // { // index.push_back(map<int, int>()); // for (auto c : cs[i]) index[i].emplace(c, j++); // } es = new vector<int>[V]; // for (int i = 0; i < V; i++) es.push_back(vector<int>()); for (int i = 0; i < M; i++) { int a = us[i], b = vs[i], c = xs[i], u = index[a][c], v = index[b][c]; es[u].push_back(v); es[v].push_back(u); } for (int i = 0; i < N; i++) for (int j = sep[i] + 1; j < sep[i + 1]; j++) { es[j].push_back(sep[i]); es[sep[i]].push_back(j); } auto d = dijkstra(0); cout << (d[sep[N - 1]] == Inf ? -1 : d[sep[N - 1]]) << endl; delete[] d; delete[] cs; delete[] sep; delete[] index; delete[] us; delete[] vs; delete[] xs; delete[] es; return 0; }
a.cc: In function 'int main()': a.cc:50:14: error: invalid conversion from 'int*' to 'int' [-fpermissive] 50 | vs = new int[M]; | ^~~~~~~~~~ | | | int* a.cc:51:14: error: invalid conversion from 'int*' to 'int' [-fpermissive] 51 | xs = new int[M]; | ^~~~~~~~~~ | | | int* a.cc:57:19: error: invalid types 'int[int]' for array subscript 57 | vs[i] = --b; | ^ a.cc:58:19: error: invalid types 'int[int]' for array subscript 58 | xs[i] = --c; | ^ a.cc:83:46: error: invalid types 'int[int]' for array subscript 83 | int a = us[i], b = vs[i], c = xs[i], u = index[a][c], v = index[b][c]; | ^ a.cc:84:28: error: 'u' was not declared in this scope 84 | es[u].push_back(v); | ^ a.cc:84:41: error: 'v' was not declared in this scope 84 | es[u].push_back(v); | ^ a.cc:100:18: error: type 'int' argument given to 'delete', expected pointer 100 | delete[] vs; | ^~ a.cc:101:18: error: type 'int' argument given to 'delete', expected pointer 101 | delete[] xs; | ^~
s199232145
p04003
C++
#include <iostream> #include <vector> #include <array> #include <map> #include <queue> int main() { std::cin.tie(0); std::ios_base::sync_with_stdio(false); for(int N,M; std::cin >> N >> M; ) { typedef std::pair<int,int> G; std::vector<std::vector<int>> g(N,std::vector<int>()); typedef std::pair<int,int> T; std::priority_queue<T,std::vector<T>,std::greater<T>> q; std::vector<G> i2t; i2t.reserve(M*2); { std::map<G,int> t2i; auto add = [&t2i,&i2t](const G&t) { if(!t2i.count(t)) { t2i[t]=i2t.size(); i2t.emplace_back(t); } }; G S(0,-1); add(S); std::vector<std::array<int,3>> pqc(M); for(auto&a:pqc) { for(auto&v:a) std::cin >> v; if(--a[0]<--a[1]) std::swap(a[0],a[1]); } std::sort(pqc.rbegin(),pqc.rend()); for(auto&a:pqc) { const auto p=a[0],q=a[1],c=a[2]; const G tq(p,c),tp(q,c); add(tp); g[p].emplace_back(t2i[tp]); add(tq); g[q].emplace_back(t2i[tq]); } q.emplace(0,t2i[S]); } std::vector<bool> u(i2t.size(),false); std::vector<int> v(N,N+1); int r=-1; while(!q.empty()) { int d,t,p,c; std::tie(d,t) = q.top(); q.pop(); std::tie(p,c) = i2t[t]; if(p == N-1){ r=d; break; } if(u[t] || v[p]<d) continue; u[t]=true; v[p]=d; for(const auto& w:g[p]) { auto e = d+(c==i2t[w].second?0:1); if(u[w] || v[i2t[w].first]<e) continue; q.emplace(e,w); } } std::cout << r << std::endl; } }
a.cc: In function 'int main()': a.cc:30:18: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 30 | std::sort(pqc.rbegin(),pqc.rend()); | ^~~~ | qsort
s379701987
p04003
C++
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #define debug(...) printf(__VA_ARGS__) #else #define debug(...) (void)0 #endif #define mp make_pair #define pb push_back #define LL long long #define pii pair<int,int> #define PII pair<long long, long long> #define fi first #define se second #define all(x) (x).begin(),(x).end() #define SZ(x) ((int)(x).size()) const int inf = 0x7fffffff; //beware overflow const LL INF = 0x7fffffffffffffff; //beware overflow #define mem(x, y) memset(x, (y), sizeof(x) ); #define IOS ios_base::sync_with_stdio(0); cin.tie(0) template<typename A, typename B> ostream& operator <<(ostream &s, const pair<A,B> &p) { return s<<"("<<p.first<<","<<p.second<<")"; } template<typename T> ostream& operator <<(ostream &s, const vector<T> &c) { s << "[ "; for (auto it : c) s << it << " "; s << "]"; return s; } template<typename T> ostream& operator << (ostream &o, const set<T> &st) { o << "{"; for (auto it=st.begin(); it!=st.end(); it++) o << (it==st.begin() ? "" : ", ") << *it; return o << "}"; } template<typename T1, typename T2> ostream& operator << (ostream &o, const map<T1, T2> &mp) { o << "{"; for (auto it=mp.begin(); it!=mp.end(); it++) { o << (it==mp.begin()?"":", ") << it->fi << ":" << it->se; } o << "}"; return o; } #define maxn 100005 int n, m; struct edge{ int u, v, c; }; vector<edge> e; vector<int> G[maxn]; int d[maxn]; set<int> Prev[maxn]; struct state{ int d; int u; bool operator < (const state& rhs) const { return mp(d, u) < mp(rhs.d, rhs.u); } }; int main() { cin>>n>>m; for(int i = 0; i < m; i++) { int p, q, c; scanf("%d %d %d", &p, &q, &c); G[p].pb( SZ(e) ); G[q].pb( SZ(e) ); e.pb( edge{p, q, c} ); } fill(d, d+1+n, 1e9); d[1] = 0; queue<state> que; que.push( state{ 0,1} ); while(!que.empty() ) { state tp = que.top(); que.pop(); int u = tp.u; if( -tp.d > d[u] ) continue; for( int e_ind : G[u] ) { int D = d[u]; int v = (e[e_ind].u==u)? e[e_ind].v:e[e_ind].u; int now = D + !Prev[u].count( e[e_ind].c); if( now < d[v] ) d[v] = now, Prev[v].clear(), Prev[v].insert(e[e_ind].c), que.push( state{ -d[v], v } ); else if (now == d[v]) Prev[v].insert( e[e_ind].c ) ; } } if( d[n] == 1e9 ) puts("-1"); else cout<<d[n]<<endl; }
a.cc: In function 'int main()': a.cc:75:32: error: 'class std::queue<state>' has no member named 'top'; did you mean 'pop'? 75 | state tp = que.top(); que.pop(); | ^~~ | pop
s976203495
p04003
C++
#include<iostream> #include<iomanip> #include<map> #include<unordered_map> #include<set> #include<unordered_set> #include<vector> #include<array> #include<string> #include<stack> #include<queue> #include<algorithm> #include<cassert> #include<functional> #include<random> #define int int64_t #define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++) #define rep(i, a) REP(i, 0, a) #define EACH(i, a) for (auto i: a) #define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++) #define ALL(a) (a.begin()), (a.end()) #define HAS(a, x) (a.find(x) != a.end()) #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) using namespace std; template<typename T>class key_Dijkstra { //各頂点が"地名"として型Tの値を持っているグラフ上でダイクストラ法をやる。 public: typedef array<int, 2> arr; vector<vector<arr>>edges;//arrは[0]が行き先の番号で、[1]が辺の長さ。 vector<T>name_list; map<T, int>index; void push_undirected_edge(const T&p1, const T&p2, const int cost) { assert(p1 != p2); int ip1, ip2; if (index.find(p1) == index.end()) { index[p1] = ip1 = name_list.size(); name_list.push_back(p1); edges.resize(edges.size() + 1); } else ip1 = index[p1]; if (index.find(p2) == index.end()) { index[p2] = ip2 = name_list.size(); name_list.push_back(p2); edges.resize(edges.size() + 1); } else ip2 = index[p2]; edges[ip1].push_back({ ip2,cost }); edges[ip2].push_back({ ip1,cost }); } void push_directed_edge(const T&src, const T&dest, const int cost) { assert(src != dest); int ip1, ip2; if (index.find(src) == index.end()) { index[src] = ip1 = name_list.size(); name_list.push_back(src); edges.resize(edges.size() + 1); } else ip1 = index[src]; if (index.find(dest) == index.end()) { index[dest] = ip2 = name_list.size(); name_list.push_back(dest); edges.resize(edges.size() + 1); } else ip2 = index[dest]; edges[ip1].push_back({ ip2,cost }); } vector<int>Dijkstra(const T start, const int INF) { //返り値はstartから各点への移動コスト。 //繋ぐ頂点が同じ辺が複数ある場合、コスト最小のもの以外を除く。 rep(i, edges.size())if(1 <= edges[i].size()){ sort(ALL(edges[i])); vector<arr>E(1,edges[i][0]); REP(j, 1, edges[i].size())if (edges[i][j - 1][0] != edges[i][j][0]) { E.push_back(edges[i][j]); } edges[i] = E; } vector<int>cost(edge_vec.size(), INF); auto itr = index.find(start); if (itr == index.end())return cost; priority_queue<arr, vector<arr>, greater<arr>>D; D.push({ 0,index[start] }); while (!D.empty()) { arr a = D.top(); D.pop(); const int now_cost = a[0]; const int now_pos = a[1]; if (cost[now_pos] <= now_cost)continue; cost[now_pos] = now_cost; for (auto x : edge_vec[now_pos]) { const int next_pos = x[0]; const int next_cost = now_cost + x[1]; D.push({ next_cost,next_pos }); } } return cost; } }; signed main(void) { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; key_Dijkstra<array<int, 2>>Dijkstra; rep(i, M) { int p, q, c; cin >> p >> q >> c; p--; q--; c--; Dijkstra.push_directed_edge({ p,c }, { p,-1 }, 0); Dijkstra.push_directed_edge({ p,-1 }, { p,c }, 1); Dijkstra.push_directed_edge({ q,c }, { q,-1 }, 0); Dijkstra.push_directed_edge({ q,-1 }, { q,c }, 1); Dijkstra.push_undirected_edge({ p,c }, { q,c }, 0); } if (M == 0 || Dijkstra.index.find({ N - 1, -1 }) == Dijkstra.index.end()) { cout << -1 << endl; return 0; } const auto costs = Dijkstra.Dijkstra({ 0,-1 }, 99999999); const int answer = costs[Dijkstra.index[{N - 1, -1}]]; if (answer == 99999999)cout << -1 << endl; else cout << answer << endl; }
a.cc: In member function 'std::vector<long int> key_Dijkstra<T>::Dijkstra(T, int64_t)': a.cc:90:33: error: 'edge_vec' was not declared in this scope 90 | vector<int>cost(edge_vec.size(), INF); | ^~~~~~~~
s679132294
p04003
C++
#include <bits/stdc++.h> #include <X11/Intrinsic.h> #include <iostream> #include <string> #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <tuple> #include <sstream> #include <typeinfo> #include <fstream> #include <random> #include <queue> #include <deque> #include <iterator> #include <map> using namespace std; #define all(c) ((c).begin()), ((c).end()) #define dump(c) cerr << "> " << #c << " = " << (c) << endl; #define iter(c) __typeof((c).begin()) #define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++) #define REP(i, a, b) for (int i = a; i < (int)(b); i++) #define rep(i, n) REP(i, 0, n) #define mp make_pair #define fst first #define snd second #define pb push_back typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<ll, ll> pll; //const int INF = 1 << 29; const ll INF= 1LL << 60; //1はint const double EPS = 1e-10; template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } template<class T> ll stoi(T &str){ ll ret; stringstream ss; ss << str; ss >> ret; return ret; } template<class T> string toString(T i) { stringstream ss; ss << i; return ss.str(); } struct prepare { prepare() { cout.setf(ios::fixed, ios::floatfield); cout.precision(8); ios_base::sync_with_stdio(false); } } _prepare; //priority_queueは最小をtopに持ってくる class Edge{ public: int to,col; Edge(){}; Edge(int b,int c){to=b,col=c;} }; class Memo{ public: ll point,kaisha,cost; bool operator<(const Memo &rhs) const { return cost < rhs.cost; } Memo(ll point, ll kaisha, ll cost) : point(point), kaisha(kaisha), cost(cost) {} }; int main(){ int N,M; cin>>N>>M; vector<vector<Edge>> graph(N); //ある点,色から伸びている辺の集合 vector<map<int, ll>> dist(N); //色とそこまでの最短コスト同じkeyなら更新されるのがミソあ vector<map<int, bool>> used(N); //ある点,色が使われているか priority_queue<Memo> que; rep(i,M){ int a,b,c; cin>>a>>b>>c; a--; b--; graph[a].pb(Edge(b,c)); graph[b].pb(Edge(a,c)); used[a][c]=false; //mapで[]を使ってアクセスすると要素がなかったときに新しい要素ができる used[b][c]=false; dist[a][c]=INF; dist[b][c]=INF; } ll ans=INF; que.push(Memo(0,0,-1)); dist[0][1]=true; while(!que.empty()){ int v=que.top().point; //pop int col=que.top().kaisha; ll cost=que.top().cost; if(v==N-1){ ans=cost; break; } que.pop(); if(used[v][col])continue; //使わない used[v][col]=true; //一度出した頂点は最短距離で決定.もう使わない for(Edge e:graph[v]){ if(dist[e.to][e.col]>cost+(col!=-1 && col!=e.col?1:0)){ dist[e.to][e.col]=cost+(col!=e.col?1:0); que.push(Memo(e.to,e.col,dist[e.to][e.col])); } } } cout<<(ans==INF?-1:ans)<<endl; return 0; }
a.cc:2:10: fatal error: X11/Intrinsic.h: No such file or directory 2 | #include <X11/Intrinsic.h> | ^~~~~~~~~~~~~~~~~ compilation terminated.
s619333597
p04003
C++
#include <iostream> #include <sstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <ctime> #include <cstring> #include <string> #include <vector> #include <stack> #include <queue> #include <deque> #include <map> #include <set> #include <bitset> #include <numeric> #include <utility> #include <iomanip> #include <algorithm> #include <functional> #include <unordered_map> using namespace std; #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template<class T> ostream& operator << (ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) { EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; } typedef pair<int,int> pint; unordered_map<pint,int> ma; vector<pint> G[110000]; int n, m; int INF = 1<<29; int dp[410000]; int solve() { deque< pair<pair<int,int>, int> > deq; for (int i = 0; i < 410000; ++i) dp[i] = INF; for (int i = 0; i < G[0].size(); ++i) { deq.push_back( make_pair(pint(0, G[0][i].second), 1) ); dp[ ma[pint(0, G[0][i].second)] ] = 1; } while (!deq.empty()) { pint node = deq.front().first; int prev = deq.front().second; deq.pop_front(); int v = node.first; int c = node.second; int idx = ma[pint(v,c)];; //if ( dp[idx] < cdp ) continue; //cout << v << ", " << c << ": " << dp[ ma[ pint(v,c) ]] << endl; for (int i = 0; i < G[v].size(); ++i) { int nv = G[v][i].first; int nc = G[v][i].second; int nidx = ma[pint(nv,nc)]; if (nv == prev) continue; //if (dp[ma[pint(nv,nc)]] < INF) continue; if (nc == c) { if (chmin(dp[nidx], dp[idx])) { deq.push_front( make_pair(pint(nv, nc), v) ); } } else { if (chmin(dp[nidx], dp[idx] + 1)) { deq.push_back( make_pair(pint(nv, nc), v) ); } } } } int res = INF; for (int i = 0; i < G[n-1].size(); ++i) { int c = G[n-1][i].second; chmin(res, dp[ ma[ pint(n-1, c)]]); } if (res >= INF) return -1; else return res; } int main() { while (cin >> n >> m) { ma.clear(); for (int i = 0; i < 110000; ++i) G[i].clear(); for (int i = 0; i < m; ++i) { int p, q, c; scanf("%d %d %d", &p, &q, &c); --p, --q, --c; G[p].push_back(pint(q, c)); G[q].push_back(pint(p, c)); ma[pint(p,c)] = 0; ma[pint(q,c)] = 0; } int con = 0; for (unordered_map<pint,int>::iterator it = ma.begin(); it != ma.end(); ++it) { it->second = con++; } cout << solve() << endl; } }
a.cc:40:25: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 40 | unordered_map<pint,int> ma; | ^~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from a.cc:20: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, 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/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of
s372084022
p04003
C++
#include <iostream> #include <sstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <ctime> #include <cstring> #include <string> #include <vector> #include <stack> #include <queue> #include <deque> #include <map> #include <set> #include <bitset> #include <numeric> #include <utility> #include <iomanip> #include <algorithm> #include <functional> #include <unordered_map> using namespace std; #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template<class T> ostream& operator << (ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) { EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; } typedef pair<int,int> pint; unordered_map<pint,int> ma; vector<pint> G[110000]; int n, m; int INF = 1<<29; int dp[410000]; int solve() { deque< pair<pair<int,int>, int> > deq; for (int i = 0; i < 410000; ++i) dp[i] = INF; for (int i = 0; i < G[0].size(); ++i) { deq.push_back( make_pair(pint(0, G[0][i].second), 1) ); dp[ ma[pint(0, G[0][i].second)] ] = 1; } while (!deq.empty()) { pint node = deq.front().first; int cdp = deq.front().second; deq.pop_front(); int v = node.first; int c = node.second; int idx = ma[pint(v,c)];; if ( dp[idx] < cdp ) continue; //cout << v << ", " << c << ": " << dp[ ma[ pint(v,c) ]] << endl; for (int i = 0; i < G[v].size(); ++i) { int nv = G[v][i].first; int nc = G[v][i].second; int nidx = ma[pint(nv,nc)]; //if (dp[ma[pint(nv,nc)]] < INF) continue; if (nc == c) { if (chmin(dp[nidx], dp[idx])) { deq.push_front( make_pair(pint(nv, nc), dp[idx]) ); } } else { if (chmin(dp[nidx], dp[idx] + 1)) { deq.push_back( make_pair(pint(nv, nc), dp[idx] + 1) ); } } } } int res = INF; for (int i = 0; i < G[n-1].size(); ++i) { int c = G[n-1][i].second; chmin(res, dp[ ma[ pint(n-1, c)]]); } if (res >= INF) return -1; else return res; } int main() { while (cin >> n >> m) { ma.clear(); for (int i = 0; i < 110000; ++i) G[i].clear(); for (int i = 0; i < m; ++i) { int p, q, c; scanf("%d %d %d", &p, &q, &c); --p, --q, --c; G[p].push_back(pint(q, c)); G[q].push_back(pint(p, c)); ma[pint(p,c)] = 0; ma[pint(q,c)] = 0; } int con = 0; for (map<pint,int>::iterator it = ma.begin(); it != ma.end(); ++it) { it->second = con++; } cout << solve() << endl; } }
a.cc:40:25: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 40 | unordered_map<pint,int> ma; | ^~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from a.cc:20: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, 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/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of
s610598643
p04003
C++
#include<iostream> #include<iomanip> #include<algorithm> #include<vector> #include<string> #include<map> #include<cmath> #include<queue> #include<functional> #include<climits> #include<tuple> #include<utility> #include<cassert> #include<stack> using namespace std; //define #define ALL(a) a.begin(),a.end() #define REP(i,n) for(int i=0;i<n;i++) #define RREP(i,n) for(int i=n-1;i>=0;i--) #define debug(x) if(1)cout<<#x<<":"<<x<<endl; #define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl; #define ll long long #define PB push_back #define LB lower_bound #define UB upper_bound //constant const int MOD = 1000000007; const int INF = INT_MAX / 3 - 1; const double EPS = 1e-9; const int dx4[4] = { 1,0,-1,0 }; const int dy4[4] = { 0,1,0,-1 }; const int dx8[8] = { -1,0,1,-1,1,-1,0,1 }; const int dy8[8] = { -1,-1,-1,0,0,1,1,1 }; //typedef typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int, int> pii; int dfs(int x, int c,int cos,vector<int> &d,const vector<vector<pair<int, int>>> &cq, priority_queue<pii, vector<pii>, greater<pii>> &s) { for(int i=distance(cq[x].begin(), lower_bound(ALL(cq[x]),c));i<distance(cq[x].begin(),upper_bound(ALL(cq[x]), c));i++) if (d[cq[x][i].second] >= cos) { if (d[cq[x][i].second] != cos) { d[cq[x][i].second] = cos; s.push(make_pair(cos, d[cq[x][i].second])); } dfs(cq[x][i].second, c, cos, d, cq, s); } return 0; } int main() { int n, m; cin >> n >> m; vector<vector<pair<int, int>>> cq(n); REP(i, m) { int p, q, c; cin >> p >> q >> c; p--; q--; c--; cq[p].push_back(make_pair(q, c)); } REP(i, n) sort(ALL(cq[i])); vector<int> d(n, INF); d[0] = 0; priority_queue<pii,vector<pii>,greater<pii>> s; s.push(make_pair(0, 0)); while(!s.empty()) { auto now=s.top(); s.pop(); for (int i = 0; i < cq[now.second].size(); i++) if (d[cq[now.second][i].second] > d[now.second]) dfs(cq[now.second][i].second, cq[now.second][i].first, d[now.second] + 1, d, cq, s); } cout << d[n - 1] << endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, 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/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = __gnu_cxx::__normal_iterator<const std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Value = const int]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<const pair<int, int>*, vector<pair<int, int> > >; _Tp = int; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<const pair<int, int>*, vector<pair<int, int> > >; _Tp = int]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:44:47: required from here 44 | for(int i=distance(cq[x].begin(), lower_bound(ALL(cq[x]),c));i<distance(cq[x].begin(),upper_bound(ALL(cq[x]), c));i++) | ~~~~~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'const std::pair<int, int>' and 'const int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<int, int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<int, int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<int, int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<int, int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<int, int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<int, int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: mismatched types 'const std::pair<_T1, _T2>' and 'const int' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<int, int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<int, int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<int, int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<int, int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3901 | operator<(const _CharT* __lhs, | ^~~~~~~~ /usr
s507951139
p04003
C++
/* * src.cpp * * Created on: 2016/09/11 * Author: joi */ #include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,a) FOR(i,0,a) typedef long long ll; typedef pair<int,int> P; const int MAX_N=1e5,INF=1e8; struct edge{ int to,type; }; struct S{ int v,type,cost; bool operator < (const S &s){ return cost>s.cost; } }; int N,M; vector<edge> G[MAX_N]; map<int,int> d[MAX_N]; //乗り換えの回数 void dijkstra(){ priority_queue<S> pq; d[0][-1]=0; pq.push(S{0,-1,0}); while (!pq.empty()){ S p=pq.top(); pq.pop(); if (d[p.v][p.type]<p.cost){ continue; } REP(i,(int)G[p.v]){ edge e=G[p.v][i]; int c=p.cost; int f=0; if (e.type!=p.type){ c++; f=1; } if (d[e.to].find(c)==d[e.to].end() || d[e.to][c]>p.cost+f){ d[e.to][c]=p.cost+f; pq.push(S{e.to,e.type,d[e.to][c]}); } } } } int main(){ scanf("%d %d",&N,&M); REP(i,M){ int p,q,c; p--; q--; G[p].push_back(edge{q,c}); G[q].push_back(edge{p,c}); } dijkstra(); int ans=INF; for (auto ite=d[N-1].begin();ite!=d[N-1].end();ite++){ ans=min(ans,ite->second); } printf("%d\n",ans); return 0; }
a.cc: In function 'void dijkstra()': a.cc:46:23: error: invalid cast from type 'std::vector<edge>' to type 'int' 46 | REP(i,(int)G[p.v]){ | ^~~~~~~~~~~ a.cc:12:37: note: in definition of macro 'FOR' 12 | #define FOR(i,a,b) for(int i=(a);i<(b);i++) | ^ a.cc:46:17: note: in expansion of macro 'REP' 46 | REP(i,(int)G[p.v]){ | ^~~ In file included from /usr/include/c++/14/string:49, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:8: /usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = S]': /usr/include/c++/14/bits/predefined_ops.h:196:23: required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<S*, std::vector<S, std::allocator<S> > >; _Value = S; _Compare = std::less<S>]' 196 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<S*, vector<S, allocator<S> > >; _Distance = long int; _Tp = S; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<S> >]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:216:23: required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<S*, vector<S, allocator<S> > >; _Compare = less<S>]' 216 | std::__push_heap(__first, _DistanceType((__last - __first) - 1), | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:747:16: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = S; _Sequence = std::vector<S, std::allocator<S> >; _Compare = std::less<S>; value_type = S]' 747 | std::push_heap(c.begin(), c.end(), comp); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:39:9: required from here 39 | pq.push(S{0,-1,0}); | ~~~~~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const S' and 'const S') 405 | { return __x < __y; } | ~~~~^~~~~ a.cc:26:14: note: candidate: 'bool S::operator<(const S&)' (near match) 26 | bool operator < (const S &s){ | ^~~~~~~~ a.cc:26:14: note: passing 'const S*' as 'this' argument discards qualifiers In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::pair<_T1, _T2>' 405 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~
s056092195
p04003
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vb = vector<bool>; using vvb = vector<vb>; using vl = vector<ll>; using vvl = vector<vl>; using vd = vector<double>; using vvd = vector<vd>; #define REP(i,n) for(ll i=0, i##_len=(ll)(n); i<i##_len; ++i) #define ALL(c) (c).begin(), (c).end() #define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i) #define TEN(x) ((ll)1e##x) const ll mod = TEN(9) + 7; int main() { #ifdef INPUT_FROM_FILE ifstream cin("sample.in"); ofstream cout("sample.out"); #endif cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(50); ll n, m; cin >> n >> m; vector<vector<pair<ll, ll>>> paths(n); // {q, c} //vector<vector<ll>> vc(n); vector<unordered_map<ll, ll>> vc(n); REP(i, m) { ll p, q, c; cin >> p >> q >> c; p--, q--, c--; paths[p].push_back({ q, c }); paths[q].push_back({ p, c }); //vc[p].push_back(c); //vc[q].push_back(c); vc[p].insert({ c, vc[p].size() }); vc[q].insert({ c, vc[q].size() }); } REP(i, n) { sort(ALL(vc[i])); vc[i].erase(unique(ALL(vc[i])), vc[i].end()); } vvl dist(n); REP(i, n) dist[i].resize(vc[i].size(), TEN(10)); REP(i, vc[0].size()) dist[0][i] = 1; typedef tuple<ll, ll, ll> P; // {dist, q, c} priority_queue<P, vector<P>, greater<P>> que; REP(i, vc[0].size()) que.push(P(1, 0, vc[0][i])); while (!que.empty()) { ll d, p, c; tie(d, p, c) = que.top(); que.pop(); ll i_c = vc[p][c];//lower_bound(ALL(vc[p]), c) - vc[p].begin(); if (dist[p][i_c] < d) continue; for (auto e : paths[p]) { ll q, nc; tie(q, nc) = e; ll i_nc = vc[q][nc];//lower_bound(ALL(vc[q]), nc) - vc[q].begin(); if (dist[q][i_nc] > dist[p][i_c] + (c != nc)) { dist[q][i_nc] = dist[p][i_c] + (c != nc); que.push(P(dist[q][i_nc], q, nc)); } } } ll ans = TEN(10); REP(i, vc[n - 1].size()) ans = min(ans, dist[n - 1][i]); cout << (ans == TEN(10) ? -1 : ans) << endl; return 0; }
In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __detail::_Node_iterator<pair<const long long int, long long int>, false, false>; _Compare = __gnu_cxx::__ops::_Iter_less_iter]': /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __detail::_Node_iterator<pair<const long long int, long long int>, false, false>]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:39:7: required from here 39 | sort(ALL(vc[i])); | ~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1906:50: error: no match for 'operator-' (operand types are 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' and 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>') 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::reverse_iterator<_Iterator>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::move_iterator<_IteratorL>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::valarray<_Tp>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::valarray<_Tp>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::valarray<_Tp>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ In file included from /usr/include/c++/14/valarray:605: /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 1906 | std::__lg(__last - __first) * 2
s677196075
p04003
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<math.h> #include<map> #include<iterator> #include<set> #include<queue> #define rep(i,n) for(int i = 0; i < n; i++) using namespace std; int main(){ int N,M; cin >> N >> M; vector<set<int>> st2ln(N+1); vector<set<int>> adj(M+1); set<int> start,end; rep(i,M){ int p,q,c; cin >> p >> q >> c; if(p == 1 || q == 1) start.insert(c); if(p == N || q == N) end.insert(c); auto itr = st2ln[p].find(c); if(st2ln[p].empty()){ st2ln[p].insert(c); continue; } else if(itr == st2ln[p].end()){ for(auto itr = st2ln[p].begin(); itr != st2ln[p].end(); itr++){ adj[c].insert(*itr); adj[*itr].insert(c); st2ln[p].insert(c); } } auto itr = st2ln[q].find(c); if(st2ln[q].empty()){ st2ln[q].insert(c); continue; } else if(itr == st2ln[q].end()){ for(auto itr = st2ln[q].begin(); itr != st2ln[q].end(); itr++){ adj[c].insert(*itr); adj[*itr].insert(c); st2ln[q].insert(c); } } } if(start.empty() || end.empty()){ cout << -1 << endl; return 0; } queue<int> que; vector<int> time(M+1, 1000000); int res = - 1; for(auto itr = start.begin(); itr != start.end(); itr++){ time[*itr] = 0; que.push(*itr); if(end.find(*itr) != end.end()){ cout << 1 << endl; return 0; } } while(!que.empty()){ int proc = que.front(); que.pop(); for(auto itr = adj[proc].begin(); itr != adj[proc].end(); itr++){ if(time[*itr] == 1000000){ time[*itr] = time[proc] + 1; que.push(*itr); if(end.find(*itr) != end.end()){ res = time[*itr]; break; } } } } if(res == -1) cout << -1 << endl; else cout << res + 1<< endl; }
a.cc: In function 'int main()': a.cc:42:22: error: conflicting declaration 'auto itr' 42 | auto itr = st2ln[q].find(c); | ^~~ a.cc:29:22: note: previous declaration as 'std::_Rb_tree_const_iterator<int> itr' 29 | auto itr = st2ln[p].find(c); | ^~~
s176089547
p04003
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<math.h> #include<map> #include<iterator> #include<set> #include<queue> #define rep(i,n) for(int i = 0; i < n; i++) using namespace std; int main(){ int N,M; cin >> N >> M; vector<set<int>> st2ln(N+1); vector<set<int>> adj(M+1); set<int> start,end; rep(i,M){ int p,q,c; cin >> p >> q >> c; if(p == 1 || q == 1) start.insert(c); if(p == N || q == N) end.insert(c); auto itr = st2ln[p].find(c); if(st2ln[p].empty()){ st2ln[p].insert(c); continue; } else if(itr == st2ln[p].end()){ for(auto itr = st2ln[p].begin(); itr != st2ln[p].end(); itr++){ adj[c].insert(*itr); adj[*itr].insert(c); st2ln[p].insert(c); } } auto itr = st2ln[q].find(c); if(st2ln[q].empty()){ st2ln[q].insert(c); continue; } else if(itr == st2ln[q].end()){ for(auto itr = st2ln[q].begin(); itr != st2ln[q].end(); itr++){ adj[c].insert(*itr); adj[*itr].insert(c); st2ln[q].insert(c); } } } if(start.empty() || end.empty()){ cout << -1 << endl; return 0; } queue<int> que; vector<int> time(M+1, 1000000); int res = - 1; for(auto itr = start.begin(); itr != start.end(); itr++){ time[*itr] = 0; que.push(*itr); if(end.find(*itr) != end.end()){ cout << 1 << endl; return 0; } } while(!que.empty()){ int proc = que.front(); que.pop(); for(auto itr = adj[proc].begin(); itr != adj[proc].end(); itr++){ if(time[*itr] == 1000000){ time[*itr] = time[proc] + 1; que.push(*itr); if(end.find(*itr) != end.end()){ res = time[*itr]; break; } } } } if(res == -1) cout << -1 << endl; else cout << res + 1<< endl; /* vector<int> time(M+1, 1000000); set<int> taboo; time[start] = 0; int prv_mini = start; rep(i,M){ if(start == end){ time[end] = 0; break; } auto mini = min_element(time.begin(), time.end()); int min_st = mini - time.begin(); if(min_st == end) break; if(*mini == 1000000) break; taboo.insert(min_st); for(auto itr = adj[min_st].begin(); itr != adj[min_st].end(); itr++){ if(taboo.find(*itr) != taboo.end()){ time[*itr] = min(time[*itr], time[min_st] + 1) } } } */ }
a.cc: In function 'int main()': a.cc:42:22: error: conflicting declaration 'auto itr' 42 | auto itr = st2ln[q].find(c); | ^~~ a.cc:29:22: note: previous declaration as 'std::_Rb_tree_const_iterator<int> itr' 29 | auto itr = st2ln[p].find(c); | ^~~
s720944874
p04003
C++
#include<iostream> #include<iomanip> #include<map> #include<unordered_set> #include<set> #include<vector> #include<array> #include<string> #include<stack> #include<queue> #include<algorithm> #include<cassert> #include<functional> #include<random> #define int int32_t #define REP(i, a, b) for (int32_t i = (int32_t)(a); i < (int32_t)(b); i++) #define rep(i, a) REP(i, 0, a) #define EACH(i, a) for (auto i: a) #define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++) #define ALL(a) (a.begin()), (a.end()) #define HAS(a, x) (a.find(x) != a.end()) #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) using namespace std; signed main(void) { cin.tie(0); ios::sync_with_stdio(false); int N,M; cin >> N >> M; vector<vector<array<int, 2>>>subway(N); rep(i, M) { int p, q, c; cin >> p >> q >> c; p--; q--; c--; subway[p].push_back({ q,c }); subway[q].push_back({ p,c }); } //subway[i]:={町iから行ける駅、その鉄道会社}の集合 typedef array<int, 3> arr;//移動コスト、現在地、現在の鉄道会社 priority_queue<arr, vector<arr>, greater<arr>>D; vector<unordered_set<int, int>>cost(N); vector<int>min_cost(N, 99999999); D.push({ 0,0,1111111 }); while (!D.empty()) { const auto a = D.top(); D.pop(); const int now_cost = a[0]; const int pos = a[1]; const int kaisha = a[2]; if (min_cost[pos] + 1 <= now_cost)continue; min_cost[pos] = min(min_cost[pos], now_cost); if (pos == N - 1)break; auto itr = cost[pos].find(kaisha); if (itr != cost[pos].end())continue; cost[pos].insert(kaisha); rep(i, subway[pos].size()) { auto next = subway[pos][i]; const int next_kaisha = next[1]; const int next_cost = now_cost + (next_kaisha == kaisha ? 0 : 1); const int next_pos = next[0]; if (min_cost[next_pos] + 1 <= next_cost)continue; auto nitr = cost[next_pos].find(next_kaisha); if (nitr != cost[next_pos].end())continue; D.push({ next_cost,next_pos,next_kaisha }); } } if (min_cost[N - 1] == 99999999)cout << -1 << endl; else cout << min_cost[N - 1] << endl; }
In file included from /usr/include/c++/14/bits/hashtable.h:35, from /usr/include/c++/14/bits/unordered_set.h:33, from /usr/include/c++/14/unordered_set:41, from a.cc:4: /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::__hash_code std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_M_hash_code(const _Key&) const [with _Key = int; _Value = int; _ExtractKey = std::__detail::_Identity; _Hash = int; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true; __hash_code = long unsigned int]': /usr/include/c++/14/bits/hashtable.h:1740:46: required from 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::iterator std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::find(const key_type&) [with _Key = int; _Value = int; _Alloc = std::allocator<int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<int>; _Hash = int; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>; iterator = std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, int, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >::iterator; key_type = int]' 1740 | __hash_code __code = this->_M_hash_code(__k); | ~~~~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/14/bits/unordered_set.h:658:25: required from 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::iterator std::unordered_set<_Value, _Hash, _Pred, _Alloc>::find(const key_type&) [with _Value = int; _Hash = int; _Pred = std::equal_to<int>; _Alloc = std::allocator<int>; iterator = std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, int, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >::iterator; key_type = int]' 658 | { return _M_h.find(__x); } | ~~~~~~~~~^~~~~ a.cc:56:28: required from here 56 | auto itr = cost[pos].find(kaisha); | ~~~~~~~~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1335:23: error: static assertion failed: hash function must be invocable with an argument of key type 1335 | static_assert(__is_invocable<const _Hash&, const _Key&>{}, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1335:23: note: 'std::__is_invocable<const int&, const int&>()' evaluates to false /usr/include/c++/14/bits/hashtable_policy.h:1337:25: error: expression cannot be used as a function 1337 | return _M_hash()(__k); | ~~~~~~~~~^~~~~ /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::__hash_code std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_M_hash_code_tr(const _Kt&) const [with _Kt = int; _Key = int; _Value = int; _ExtractKey = std::__detail::_Identity; _Hash = int; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true; __hash_code = long unsigned int]': /usr/include/c++/14/bits/hashtable.h:2329:44: required from 'std::pair<typename std::__detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::iterator, bool> std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_M_insert_unique(_Kt&&, _Arg&&, const _NodeGenerator&) [with _Kt = const int&; _Arg = const int&; _NodeGenerator = std::__detail::_AllocNode<std::allocator<std::__detail::_Hash_node<int, true> > >; _Key = int; _Value = int; _Alloc = std::allocator<int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<int>; _Hash = int; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>; typename std::__detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::iterator = std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, int, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >::iterator; typename _Traits::__constant_iterators = std::__detail::_Hashtable_traits<true, true, true>::__constant_iterators]' 2329 | __hash_code __code = this->_M_hash_code_tr(__k); | ~~~~~~~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/14/bits/hashtable.h:947:27: required from 'std::pair<typename std::__detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::iterator, bool> std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_M_insert_unique_aux(_Arg&&, const _NodeGenerator&) [with _Arg = const int&; _NodeGenerator = std::__detail::_AllocNode<std::allocator<std::__detail::_Hash_node<int, true> > >; _Key = int; _Value = int; _Alloc = std::allocator<int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<int>; _Hash = int; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>; typename std::__detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::iterator = std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, int, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >::iterator; typename _Traits::__constant_iterators = std::__detail::_Hashtable_traits<true, true, true>::__constant_iterators]' 947 | return _M_insert_unique( | ~~~~~~~~~~~~~~~~^ 948 | _S_forward_key(_ExtractKey{}(std::forward<_Arg>(__arg))), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 949 | std::forward<_Arg>(__arg), __node_gen); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:959:31: required from 'std::pair<typename std::__detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::iterator, bool> std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_M_insert(_Arg&&, const _NodeGenerator&, std::true_type) [with _Arg = const int&; _NodeGenerator = std::__detail::_AllocNode<std::allocator<std::__detail::_Hash_node<int, true> > >; _Key = int; _Value = int; _Alloc = std::allocator<int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<int>; _Hash = int; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>; typename std::__detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::iterator = std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, int, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >::iterator; typename _Traits::__constant_iterators = std::__detail::_Hashtable_traits<true, true, true>::__constant_iterators; std::true_type = std::true_type]' 959 | return _M_insert_unique_aux( | ~~~~~~~~~~~~~~~~~~~~^ 960 | __to_value{}(std::forward<_Arg>(__arg)), __node_gen); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:958:22: required from 'std::__detail::_Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::__ireturn_type std::__detail::_Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::insert(const value_type&) [with _Key = int; _Value = int; _Alloc = std::allocator<int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<int>; _Hash = int; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>; __ireturn_type = std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, int, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >::__ireturn_type; value_type = int]' 958 | return __h._M_insert(__v, __node_gen, __unique_keys{}); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_set.h:429:27: required from 'std::pair<typename std::_Hashtable<_Value, _Value, _Alloc, std::__detail::_Identity, _Pred, _Hash, std::__detail::_Mod_range_hashing,
s871406031
p04003
C++
#include <bits/stdc++.h> using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i,n) for (int i=0;i<(n);i++) #define rep2(i,a,b) for (int i=(a);i<(b);i++) #define rrep(i,n) for (int i=(n)-1;i>=0;i--) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl #define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;} #define printP(p) cout << p.first << " " << p.second << endl #define printVP(vp) for(auto&& p : vp) printP(p); typedef long long ll; typedef pair<int, int> Pii; // typedef tuple<int, int, int> TUPLE; typedef tuple<int, int, int, int> TUPLE; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<Pii> vp; const int inf = 1e9; const int mod = 1e9 + 7; // template<typename T> using Graph = vector<vector<T>>; struct edge { int to, id; edge(){} edge(int _to, int _id) : to(_to), id(_id) {} }; typedef vector<vector<edge>> Graph; int dijkstra(const Graph& G, int s, int g) { int N = G.size(); priority_queue<TUPLE, vector<TUPLE>, greater<TUPLE>> pq; // {cost, id, v, pre} set<TUPLE> st; vi d(N, inf); d[s] = 0; pq.push(make_tuple(0, -1, s, -1)); st.insert(make_tuple(0, -1, s, -1)); while (!pq.empty()) { int cost, id, v, pre; tie(cost, id, v, pre) = pq.top(); pq.pop(); if (v == g) break; if (d[v] < cost) continue; for (const auto& e : G[v]) { if (e.to == pre) continue; if (d[e.to] >= d[v] + (e.id != id)) { d[e.to] = d[v] + (e.id != id); if (st.count(make_tuple(d[e.to], e.id, e.to))) continue; pq.push(make_tuple(d[e.to], e.id, e.to, v)); st.insert(make_tuple(d[e.to], e.id, e.to)); } } } return d[g]; } signed main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int N, M; cin >> N >> M; Graph G(N); rep(i, M) { int p, q, c; cin >> p >> q >> c; p--, q--; G[p].emplace_back(q, c); G[q].emplace_back(p, c); } int ans = dijkstra(G, 0, N - 1); if (ans == inf) ans = -1; cout << ans << endl; }
a.cc: In function 'long long int dijkstra(const Graph&, long long int, long long int)': a.cc:53:29: error: no matching function for call to 'std::set<std::tuple<long long int, long long int, long long int, long long int> >::count(std::tuple<long long int, long long int, long long int>)' 53 | if (st.count(make_tuple(d[e.to], e.id, e.to))) continue; | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/set:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158, from a.cc:1: /usr/include/c++/14/bits/stl_set.h:756:9: note: candidate: 'template<class _Kt> decltype (((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::set<_Key, _Compare, _Alloc>::count(const _Kt&) const [with _Key = std::tuple<long long int, long long int, long long int, long long int>; _Compare = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >]' 756 | count(const _Kt& __x) const | ^~~~~ /usr/include/c++/14/bits/stl_set.h:756:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype (((const std::set<std::tuple<long long int, long long int, long long int, long long int> >*)this)->std::set<std::tuple<long long int, long long int, long long int, long long int> >::_M_t.std::_Rb_tree<std::tuple<long long int, long long int, long long int, long long int>, std::tuple<long long int, long long int, long long int, long long int>, std::_Identity<std::tuple<long long int, long long int, long long int, long long int> >, std::less<std::tuple<long long int, long long int, long long int, long long int> >, std::allocator<std::tuple<long long int, long long int, long long int, long long int> > >::_M_count_tr<_Kt, _Req>(__x)) std::set<std::tuple<long long int, long long int, long long int, long long int> >::count(const _Kt&) const [with _Kt = std::tuple<long long int, long long int, long long int>]': a.cc:53:29: required from here 53 | if (st.count(make_tuple(d[e.to], e.id, e.to))) continue; | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_set.h:757:37: error: no matching function for call to 'std::_Rb_tree<std::tuple<long long int, long long int, long long int, long long int>, std::tuple<long long int, long long int, long long int, long long int>, std::_Identity<std::tuple<long long int, long long int, long long int, long long int> >, std::less<std::tuple<long long int, long long int, long long int, long long int> >, std::allocator<std::tuple<long long int, long long int, long long int, long long int> > >::_M_count_tr(const std::tuple<long long int, long long int, long long int>&) const' 757 | -> decltype(_M_t._M_count_tr(__x)) | ~~~~~~~~~~~~~~~~^~~~~ In file included from /usr/include/c++/14/map:62, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152: /usr/include/c++/14/bits/stl_tree.h:1311:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Req = _Kt; _Key = std::tuple<long long int, long long int, long long int, long long int>; _Val = std::tuple<long long int, long long int, long long int, long long int>; _KeyOfValue = std::_Identity<std::tuple<long long int, long long int, long long int, long long int> >; _Compare = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >]' 1311 | _M_count_tr(const _Kt& __k) const | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1311:9: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/string:49, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _SfinaeType = std::tuple<long long int, long long int, long long int>]': /usr/include/c++/14/bits/stl_tree.h:1309:9: required by substitution of 'template<class _Kt> decltype (((const std::set<std::tuple<long long int, long long int, long long int, long long int> >*)this)->std::set<std::tuple<long long int, long long int, long long int, long long int> >::_M_t.std::_Rb_tree<std::tuple<long long int, long long int, long long int, long long int>, std::tuple<long long int, long long int, long long int, long long int>, std::_Identity<std::tuple<long long int, long long int, long long int, long long int> >, std::less<std::tuple<long long int, long long int, long long int, long long int> >, std::allocator<std::tuple<long long int, long long int, long long int, long long int> > >::_M_count_tr<_Kt, _Req>(__x)) std::set<std::tuple<long long int, long long int, long long int, long long int> >::count(const _Kt&) const [with _Kt = std::tuple<long long int, long long int, long long int>]' 1309 | typename _Req = __has_is_transparent_t<_Compare, _Kt>> | ^~~~~~~~ a.cc:53:29: required from here 53 | if (st.count(make_tuple(d[e.to], e.id, e.to))) continue; | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::tuple<long long int, long long int, long long int, long long int> >, std::tuple<long long int, long long int, long long int>, void>' 1427 | using __has_is_transparent_t | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_set.h:750:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::tuple<long long int, long long int, long long int, long long int>; _Compare = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >; size_type = long unsigned int; key_type = std::tuple<long long int, long long int, long long int, long long int>]' 750 | count(const key_type& __x) const | ^~~~~ /usr/include/c++/14/bits/stl_set.h:750:29: note: no known conversion for argument 1 from 'std::tuple<long long int, long long int, long long int>' to 'const std::set<std::tuple<long long int, long long int, long long int, long long int> >::key_type&' {aka 'const std::tuple<long long int, long long int, long long int, long long int>&'} 750 | count(const key_type& __x) const | ~~~~~~~~~~~~~~~~^~~ a.cc:55:26: error: no matching function for call to 'std::set<std::tuple<long long int, long long int, long long int, long long int> >::insert(std::tuple<long long int, long long int, long long int>)' 55 | st.insert(make_tuple(d[e.to], e.id, e.to)); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_set.h:568:9: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = std::tuple<long long int, long long int, long long int, long long int>; _Compare = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >]' 568 | insert(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/14/bits/stl_set.h:568:9: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_set.h:511:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::tuple<long long int, long long int, long long int, long long int>; _Compare = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::tuple<long long int, long long int, long long int, long long int>, std::tuple<long long int, long long int, long long int, long long int>, std::_Identity<std::tuple<long long int, long long int, long long int, long long int> >, std::less<std::tuple<long long int, long long int, long long int, long long int> >, std::allocator<std::tuple<long long int, long long int, long long int, long long int> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::tuple<long long int, long long int, long long int, long long int> >, std::tuple<long long int, long long int, long long int, long long int> >::rebind<std::tuple<long long int, long long int, long long int, long long int> >; typename _Alloc::value_type = std::tuple<long long int, long long int, long long int, long long int>; value_type = std::tuple<long long int, long long int, long long int, long long int>]' 511 | insert(const value_type& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_set.h:511:32: note: no known conversion for argument 1 from 'std::tuple<long long int, long
s866706290
p04003
C++
#include<iostream> #include<iomanip> #include<map> #include<unordered_map> #include<set> #include<vector> #include<array> #include<string> #include<stack> #include<queue> #include<algorithm> #include<cassert> #include<functional> #include<random> #define int int32_t #define REP(i, a, b) for (int32_t i = (int32_t)(a); i < (int32_t)(b); i++) #define rep(i, a) REP(i, 0, a) #define EACH(i, a) for (auto i: a) #define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++) #define ALL(a) (a.begin()), (a.end()) #define HAS(a, x) (a.find(x) != a.end()) #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) using namespace std; signed main(void) { cin.tie(0); ios::sync_with_stdio(false); int N,M; cin >> N >> M; vector<vector<array<int, 2>>>subway(N); rep(i, M) { int p, q, c; cin >> p >> q >> c; p--; q--; c--; subway[p].push_back({ q,c }); subway[q].push_back({ p,c }); } //subway[i]:={町iから行ける駅、その鉄道会社}の集合 typedef array<int, 3> arr;//移動コスト、現在地、現在の鉄道会社 priority_queue<arr, vector<arr>, greater<arr>>D; vector<unordered_map<int, int>>cost(N); vector<int>min_cost(N, 99999999); D.push({ 0,0,1111111 }); while (!D.empty()) { const auto a = D.top(); D.pop(); const int now_cost = a[0]; const int pos = a[1]; const int kaisha = a[2]; if (min_cost[pos] + 2 <= now_cost)continue; min_cost[pos] = min(min_cost[pos], now_cost); if (pos == N - 1)break; auto itr = cost[pos].find(kaisha); if (itr != cost[pos].end())continue; cost[pos][kaisha] = now_cost; rep(i,subway[pos].size()) { auto next = subway[pos][i]; if (next[pos][i][0] == 99999999)continue; const int next_kaisha = next[1]; const int next_cost = now_cost + (next_kaisha == kaisha ? 0 : 1); const int next_pos = next[0]; if (min_cost[next_pos] + 2 <= next_cost)continue; auto nitr = cost[next_pos].find(next_kaisha); if (nitr != cost[next_pos].end())continue; D.push({ next_cost,next_pos,next_kaisha }); subway[pos][i][0] = 99999999; } } if (min_cost[N - 1] == 99999999)cout << -1 << endl; else cout << min_cost[N - 1] << endl; }
a.cc: In function 'int main()': a.cc:61:38: error: invalid types 'std::array<int, 2>::value_type {aka int}[int32_t {aka int}]' for array subscript 61 | if (next[pos][i][0] == 99999999)continue; | ^
s549218235
p04003
C++
#include <bits/stdc++.h> using namespace std; #define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i) #define REPU(i, a, b) for (int i = (a); i < (b); ++i) #define REPD(i, a, b) for (int i = (a); i > (b); --i) #define MEM(a, x) memset(a, x, sizeof(a)) #define ALL(a) a.begin(), a.end() #define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) vector<string> split(const string &s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(x); return v; } #define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); } void err(vector<string>::iterator it) {} template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) { cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n'; err(++it, args...); } typedef long long ll; const int MOD = 1000000007; template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; } template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; } template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; } template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; } template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; } template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; } typedef pair<int, int> P; const int N = 100001, C = 1000001, INF = (int) 1e9; struct E { int to, fac; }; int d[N]; vector<E> g[N]; unorederd_map<int, bool> colors[N]; struct State { int vertex, cost, color; State() {} State(int _v, int cs, int cl) : vertex(_v), cost(cs), color(cl) {} }; struct Comp { bool operator() (const State &s1, const State &s2) const { return s1.cost > s2.cost; }; }; void dijkstra(int s, int t) { priority_queue<State, vector<State>, Comp> que; fill(d, d + N, INF); d[s] = 0; que.push(State(s, 0, -1)); while (!que.empty()) { auto p = que.top(); que.pop(); if (d[p.vertex] < p.cost) continue; if (p.cost - d[t] >= 1) return; REPU(i, 0, g[p.vertex].size()) { E e = g[p.vertex][i]; int cost = 1; if (e.fac == p.color) cost = 0; if (d[e.to] > d[p.vertex] + cost) { colors[e.to].clear(); colors[e.to][e.fac] = 1; d[e.to] = d[p.vertex] + cost; que.push(State(e.to, d[e.to], e.fac)); } else if (d[e.to] == d[p.vertex] + cost) { if (colors[e.to].count(e.fac) == 0) { que.push(State(e.to, d[e.to], e.fac)); colors[e.to][e.fac] = 1; } } } } } int main(int argc, char *argv[]) { ios_base::sync_with_stdio(false); int n, m, p, q, c; cin >> n >> m; REPU(_, 0, m) { cin >> p >> q >> c; g[p].push_back((E) {q, c}); g[q].push_back((E) {p, c}); } dijkstra(1, n); if (d[n] == INF) d[n] = -1; cout << d[n] << endl; return 0; }
a.cc:46:1: error: 'unorederd_map' does not name a type 46 | unorederd_map<int, bool> colors[N]; | ^~~~~~~~~~~~~ a.cc: In function 'void dijkstra(int, int)': a.cc:73:33: error: 'colors' was not declared in this scope 73 | colors[e.to].clear(); | ^~~~~~ a.cc:79:37: error: 'colors' was not declared in this scope 79 | if (colors[e.to].count(e.fac) == 0) { | ^~~~~~
s477819343
p04003
C++
#define PB push_back #define SZ(x) (int)x.size() #define MP make_pair #define F first #define S second using namespace std; typedef pair<int,int> pii; typedef pair<pii,int> piii; const int maxn=1e5+5; struct Edge {int from,to,type;}; vector<Edge> edges; vector<int> G[maxn]; map<int,int> d[maxn]; int done[maxn],Mind[maxn]; int n; const int INF=0x3f3f3f3f; int dijkstra(const int& st,const int& ed) { priority_queue<piii,vector<piii>,greater<piii> > pq; for(int i=0;i<n;i++) d[i].clear(),done[i]=0,Mind[i]=INF; pq.push(MP(MP(0,st),-1)); Mind[st]=0; while(!pq.empty()) { piii x=pq.top();pq.pop(); int now=x.F.S,lasttype=x.S,noww=x.F.F; if(done[now]) continue; done[now]=1; for(const int& num:G[now]) { Edge& e=edges[num]; int to = e.from == now ? e.to : e.from; if(Mind[to]+1>noww+(lasttype==e.type?0:1) && (!(d[to].count(e.type)) || d[to][e.type]>noww+(lasttype == e.type?0:1))) { d[to][e.type]=noww+(lasttype == e.type?0:1); Mind[to]=min(Mind[to],noww+(lasttype== e.type?0:1)); pq.push(MP(MP(noww+(lasttype == e.type?0:1),to),e.type)); } } } int ans=INF; for(auto&& it:d[ed]) ans=min(ans,it.S); return ans == INF ? -1 : ans; } int main() { int m; scanf("%d%d",&n,&m); for(int i=0,a,b,c;i<m;i++) { scanf("%d%d%d",&a,&b,&c);a--,b--; edges.PB((Edge){a,b,c}); G[a].PB(SZ(edges)-1); G[b].PB(SZ(edges)-1); } printf("%d\n",dijkstra(0,n-1)); }
a.cc:7:9: error: 'pair' does not name a type 7 | typedef pair<int,int> pii; | ^~~~ a.cc:8:9: error: 'pair' does not name a type 8 | typedef pair<pii,int> piii; | ^~~~ a.cc:11:1: error: 'vector' does not name a type 11 | vector<Edge> edges; | ^~~~~~ a.cc:12:1: error: 'vector' does not name a type 12 | vector<int> G[maxn]; | ^~~~~~ a.cc:13:1: error: 'map' does not name a type 13 | map<int,int> d[maxn]; | ^~~ a.cc: In function 'int dijkstra(const int&, const int&)': a.cc:19:5: error: 'priority_queue' was not declared in this scope 19 | priority_queue<piii,vector<piii>,greater<piii> > pq; | ^~~~~~~~~~~~~~ a.cc:1:1: note: 'std::priority_queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>' +++ |+#include <queue> 1 | #define PB push_back a.cc:19:20: error: 'piii' was not declared in this scope 19 | priority_queue<piii,vector<piii>,greater<piii> > pq; | ^~~~ a.cc:19:25: error: 'vector' was not declared in this scope 19 | priority_queue<piii,vector<piii>,greater<piii> > pq; | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | #define PB push_back a.cc:19:37: error: expected primary-expression before ',' token 19 | priority_queue<piii,vector<piii>,greater<piii> > pq; | ^ a.cc:19:38: error: 'greater' was not declared in this scope 19 | priority_queue<piii,vector<piii>,greater<piii> > pq; | ^~~~~~~ a.cc:19:52: error: expected primary-expression before '>' token 19 | priority_queue<piii,vector<piii>,greater<piii> > pq; | ^ a.cc:19:54: error: 'pq' was not declared in this scope 19 | priority_queue<piii,vector<piii>,greater<piii> > pq; | ^~ a.cc:20:26: error: 'd' was not declared in this scope 20 | for(int i=0;i<n;i++) d[i].clear(),done[i]=0,Mind[i]=INF; | ^ a.cc:3:12: error: 'make_pair' was not declared in this scope 3 | #define MP make_pair | ^~~~~~~~~ a.cc:21:16: note: in expansion of macro 'MP' 21 | pq.push(MP(MP(0,st),-1)); | ^~ a.cc:1:1: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>' +++ |+#include <utility> 1 | #define PB push_back a.cc:3:12: error: 'make_pair' was not declared in this scope 3 | #define MP make_pair | ^~~~~~~~~ a.cc:21:13: note: in expansion of macro 'MP' 21 | pq.push(MP(MP(0,st),-1)); | ^~ a.cc:3:12: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>' 3 | #define MP make_pair | ^~~~~~~~~ a.cc:21:13: note: in expansion of macro 'MP' 21 | pq.push(MP(MP(0,st),-1)); | ^~ a.cc:25:13: error: expected ';' before 'x' 25 | piii x=pq.top();pq.pop(); | ^~ | ; a.cc:26:17: error: 'x' was not declared in this scope 26 | int now=x.F.S,lasttype=x.S,noww=x.F.F; | ^ a.cc:29:28: error: 'G' was not declared in this scope 29 | for(const int& num:G[now]) | ^ a.cc:31:21: error: 'edges' was not declared in this scope 31 | Edge& e=edges[num]; | ^~~~~ a.cc:33:27: error: 'noww' was not declared in this scope; did you mean 'now'? 33 | if(Mind[to]+1>noww+(lasttype==e.type?0:1) && | ^~~~ | now a.cc:33:33: error: 'lasttype' was not declared in this scope 33 | if(Mind[to]+1>noww+(lasttype==e.type?0:1) && | ^~~~~~~~ a.cc:34:20: error: 'd' was not declared in this scope 34 | (!(d[to].count(e.type)) || d[to][e.type]>noww+(lasttype == e.type?0:1))) | ^ a.cc:37:26: error: 'min' was not declared in this scope 37 | Mind[to]=min(Mind[to],noww+(lasttype== e.type?0:1)); | ^~~ a.cc:43:19: error: 'd' was not declared in this scope; did you mean 'ed'? 43 | for(auto&& it:d[ed]) ans=min(ans,it.S); | ^ | ed a.cc:43:30: error: 'min' was not declared in this scope 43 | for(auto&& it:d[ed]) ans=min(ans,it.S); | ^~~ a.cc: In function 'int main()': a.cc:49:5: error: 'scanf' was not declared in this scope 49 | scanf("%d%d",&n,&m); | ^~~~~ a.cc:53:9: error: 'edges' was not declared in this scope 53 | edges.PB((Edge){a,b,c}); | ^~~~~ a.cc:54:9: error: 'G' was not declared in this scope 54 | G[a].PB(SZ(edges)-1); | ^ a.cc:57:5: error: 'printf' was not declared in this scope 57 | printf("%d\n",dijkstra(0,n-1)); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | #define PB push_back
s954717397
p04003
C++
//by tzupengwang™ #include<set> #include<algorithm> #include<cstdio> #include<queue> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; int n , m ; ii edg[ 400005 ] ; int cpy[ 400005 ] ; vector< int > v[ 100005 ] ; set< int > st[ 100005 ] ; int dis[ 400005 ] ; void init() { scanf( "%d%d" , &n , &m ) ; for ( int i = 0 ; i < m ; i ++ ) { int x , y , z ; scanf( "%d%d%d" , &x , &y , &z ) ; edg[ i * 2 ] = ii( x , y ) ; cpy[ i * 2 ] = z ; v[ x ].push_back( i * 2 ) ; edg[ i * 2 + 1 ] = ii( y , x ) ; cpy[ i * 2 + 1 ] = z ; v[ y ].push_back( i * 2 + 1 ) ; } } priority_queue< ii , vector< ii > , greater< ii > > pq ; void process() { memset( dis , -1 , sizeof dis ) ; for ( int id : v[ 1 ] ) { pq.push( ii( 1 , id ) ) ; } while ( !pq.empty() ) { ii nnw = pq.top() ; pq.pop() ; int nid = nnw.second , dss = nnw.first ; int now = edg[ nid ].second ; int nwc = cpy[ nid ] ; if ( now == n ) { printf( "%d\n" , dss ) ; return ; } if ( dis[ nid ] != -1 ) continue ; dis[ nid ] = dss ; if ( st[ now ].count( nwc ) ) continue ; if ( st[ now ].size() == 0 ) { for ( int id : v[ now ] ) if ( dis[ id ] == -1 ) { if ( nwc == cpy[ id ] ) { pq.push( ii( dss , id ) ) ; } else { pq.push( ii( dss + 1 , id ) ) ; } } } else { for ( int id : v[ now ] ) if ( dis[ id ] == -1 ) { if ( nwc == cpy[ id ] ) { pq.push( ii( dss , id ) ) ; } } } st[ now ].insert( cpy[ nid ] ) ; } printf( "-1\n" ) ; } int main() { init() ; process() ; return 0 ; }
a.cc: In function 'void process()': a.cc:36:3: error: 'memset' was not declared in this scope 36 | memset( dis , -1 , sizeof dis ) ; | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<queue> +++ |+#include <cstring> 6 | using namespace std;
s306912024
p04003
C++
#include <queue> #include <vector> using namespace std; bool seen[500005]; int N, M; vector<int> adj[200005]; vector<pair<int,int>> e; int bfs() { deque<pair<int, int>> q; q.push_back({0,0}); while(!q.empty()) { pair<int, int> cur = q.front(); q.pop_front(); int eID = cur.first; int dist = cur.second; int at = e[eID].first; int col = e[eID].second; if(seen[eID]) { continue; } seen[eID] = true; if(at == N) { return dist; } for(auto edge: adj[at]) { int to = e[edge].first; int tocol = e[edge].second; if(seen[edge]) { continue; } if(tocol == col) { q.push_front({edge,dist}); } else { q.push_back ({edge,dist+1}); } } } return -1; } int main() { cin >> N >> M; e.push_back({1,-1}); for(int i = 1; i <= M; i++) { int a, b, c; cin >> a >> b >> c; e.push_back({b,c}); adj[a].push_back(e.size()-1); e.push_back({a,c}); adj[b].push_back(e.size()-1); } cout << bfs() << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:47:5: error: 'cin' was not declared in this scope 47 | cin >> N >> M; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <queue> +++ |+#include <iostream> 2 | #include <vector> a.cc:57:5: error: 'cout' was not declared in this scope 57 | cout << bfs() << "\n"; | ^~~~ a.cc:57:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s108774194
p04003
C++
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <algorithm> using namespace std; #define REP(i,n) for(int i=0; i<n; ++i) #define FOR(i,a,b) for(int i=a; i<=b; ++i) #define FORR(i,a,b) for (int i=a; i>=b; --i) #define pi M_PI typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; typedef vector<VI> VVI; typedef pair<int,int> P; typedef pair<ll,ll> PL; typedef pair<int,P> tuple; #define INF 1e9 int d[100000]; vector<P> e[100000]; int main() { int n, m; cin >> n >> m; REP(i,m){ int p, q, c; scanf("%d %d %d", &p, &q, &c); p--; q--; e[p].push_back(make_pair(q, c)); e[q].push_back(make_pair(p, c)); } REP(i,n) d[i] = INF; d[0] = 0; priority_queue<tuple,vector<tuple>,greater<tuple> > pq; pq.push(make_pair(0,make_pair(0,0))); while (!pq.empty() && d[n-1] == INF){ tuple a = pq.top(); pq.pop(); int dist = a.first; int now = a.second.first; int c = a.second.second; if(d[now] < dist) continue; REP(i,e[now].size()){ P ne = e[now][i]; int next = ne.first, cc = ne.second; int cost = (c != cc); if (d[next]>d[now]+cost){ d[next]=d[now]+cost; pq.push(make_pair(d[next],make_pair(next,cc))); } } } if (d[n-1] == INF) cout << -1 << endl; else cout << d[n-1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:49:38: error: template argument 1 is invalid 49 | priority_queue<tuple,vector<tuple>,greater<tuple> > pq; | ^ a.cc:49:38: error: template argument 2 is invalid a.cc:49:53: error: template argument 1 is invalid 49 | priority_queue<tuple,vector<tuple>,greater<tuple> > pq; | ^ a.cc:49:55: error: template argument 1 is invalid 49 | priority_queue<tuple,vector<tuple>,greater<tuple> > pq; | ^ a.cc:49:55: error: template argument 2 is invalid a.cc:49:55: error: template argument 3 is invalid a.cc:50:8: error: request for member 'push' in 'pq', which is of non-class type 'int' 50 | pq.push(make_pair(0,make_pair(0,0))); | ^~~~ a.cc:51:16: error: request for member 'empty' in 'pq', which is of non-class type 'int' 51 | while (!pq.empty() && d[n-1] == INF){ | ^~~~~ a.cc:52:9: error: reference to 'tuple' is ambiguous 52 | tuple a = pq.top(); | ^~~~~ 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:92:11: note: candidates are: 'template<class ...> class std::tuple' 92 | class tuple; | ^~~~~ a.cc:26:21: note: 'typedef struct std::pair<int, std::pair<int, int> > tuple' 26 | typedef pair<int,P> tuple; | ^~~~~ a.cc:53:12: error: request for member 'pop' in 'pq', which is of non-class type 'int' 53 | pq.pop(); | ^~~ a.cc:54:20: error: 'a' was not declared in this scope 54 | int dist = a.first; | ^ a.cc:64:20: error: request for member 'push' in 'pq', which is of non-class type 'int' 64 | pq.push(make_pair(d[next],make_pair(next,cc))); | ^~~~
s974290132
p04003
C++
#include <bits/stdc++.h> #define FOR(i,a,b) for(LL i=(a);i<(LL)(b);i++) #define REP(i,b) FOR(i,0,b) #define ALL(c) c.begin(),c.end() #define PB push_back #define FF first #define SS second #define cat //cout << __LINE__ << endl; using namespace std; typedef long long LL; typedef double ld; typedef LL ut; typedef vector<ut> VI; typedef pair<ut,ut> pr; typedef pair<ut,pr> ppr; typedef vector<pr> Vpr; typedef vector<ppr> Vppr; typedef priority_queue<pr,Vpr,greater<pr> > PQ; const ut INF=1LL<<30; const int SIZE=5+1e5; map<LL,LL> searched; Vpr edge[SIZE]; VI miniumed[SIZE]; LL minium[SIZE]; LL p[SIZE],q[SIZE],c[SIZE]; int main(){ int N,M; cin.tie(0); cin >> N >> M; FOR(i,1,N+1) minium[i]=INF; REP(i,M){ cin >> p[i] >> q[i] >> c[i]; edge[p[i]].PB(pr(c[i],q[i])); edge[q[i]].PB(pr(c[i],p[i])); } FOR(i,1,N+1){ sort(ALL(edge[i])); miniumed[i].PB(INF); } PQ qu; qu.push(pr(0,1)); while(!qu.empty()){ LL dist=qu.top().first,now=qu.top().second; qu.pop(); if(miniumed[now]<dist) continue; searched[now]=true; sort(ALL(miniumed[now])); int ces=0; REP(i,edge[now].size()){ int next=edge[now][i].second; int nuse=edge[now][i].first; while(miniumed[now][ces]<nuse) ces++; LL ndist=dist+(nuse!=miniumed[now][ces]); if(minium[next]>=ndist){ if(minium[next]>ndist) miniumed[next].clear(); minium[next]=ndist; miniumed[next].PB(nuse); qu.push(pr(ndist,next)); } } } if(minium[N]==INF) cout << -1 << endl; else cout << minium[N] << endl; return 0; }
a.cc: In function 'int main()': a.cc:45:33: error: no match for 'operator<' (operand types are 'VI' {aka 'std::vector<long long int>'} and 'LL' {aka 'long long int'}) 45 | if(miniumed[now]<dist) continue; | ~~~~~~~~~~~~~^~~~~ | | | | | LL {aka long long int} | VI {aka std::vector<long long int>} In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'VI' {aka 'std::vector<long long int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'VI' {aka 'std::vector<long long int>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'VI' {aka 'std::vector<long long int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:45:34: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'LL' {aka 'long long int'} 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'VI' {aka 'std::vector<long long int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:45:34: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'LL' {aka 'long long int'} 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'VI' {aka 'std::vector<long long int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 45 | if(miniumed[now]<dist) continue; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'VI' {aka 'std::vector<long long int>'} is not derived from 'const std::pair<_T1, _T2>' 45 | if(miniumed[now]<dist) continue; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'VI' {aka 'std::vector<long long int>'} is not derived from 'const std::reverse_iterator<_Iterator>' 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'VI' {aka 'std::vector<long long int>'} is not derived from 'const std::reverse_iterator<_Iterator>' 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'VI' {aka 'std::vector<long long int>'} is not derived from 'const std::move_iterator<_IteratorL>' 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'VI' {aka 'std::vector<long long int>'} is not derived from 'const std::move_iterator<_IteratorL>' 45 | if(miniumed[now]<dist) continue; | ^~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'std::vector<long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:45:34: note: 'std::vector<long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 45 | if(miniumed[now]<dist) continue; | ^~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: a.cc:45:34: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int' 45 | if(miniumed[
s504095482
p04003
C++
#include <bits/stdc++.h> #define FOR(i,a,b) for(LL i=(a);i<(LL)(b);i++) #define REP(i,b) FOR(i,0,b) #define ALL(c) c.begin(),c.end() #define PB push_back #define FF first #define SS second #define cat //cout << __LINE__ << endl; using namespace std; typedef long long LL; typedef double ld; typedef LL ut; typedef vector<ut> VI; typedef pair<ut,ut> pr; typedef pair<ut,pr> ppr; typedef vector<pr> Vpr; typedef vector<ppr> Vppr; typedef priority_queue<pr,Vpr,greater<pr> > PQ; const ut INF=1LL<<30; const int SIZE=5+1e5; map<LL,LL> searched; Vpr edge[SIZE]; VI miniumed[SIZE]; LL minium[SIZE]; LL p[SIZE],q[SIZE],c[SIZE]; int main(){ int N,M; cin.tie(0); cin >> N >> M; FOR(i,1,N+1) minium[i]=INF; REP(i,M){ cin >> p[i] >> q[i] >> c[i]; edge[p[i]].PB(pr(c[i],q[i])); edge[q[i]].PB(pr(c[i],p[i])); } FOR(i,1,N+1){ sort(ALL(edge[i])); miniumed[i].PB(INF); } PQ qu; qu.push(pr(0,1)); while(!qu.empty()){ LL dist=qu.top().first,now=qu.top().second; qu.pop(); if(miniumed[now]) continue; searched[now]=true; sort(ALL(miniumed[now])); int ces=0; REP(i,edge[now].size()){ int next=edge[now][i].second; int nuse=edge[now][i].first; while(miniumed[now][ces]<nuse) ces++; LL ndist=dist+(nuse!=miniumed[now][ces]); if(minium[next]>=ndist){ if(minium[next]>ndist) miniumed[next].clear(); minium[next]=ndist; miniumed[next].PB(nuse); qu.push(pr(ndist,next)); } } } if(minium[N]==INF) cout << -1 << endl; else cout << minium[N] << endl; return 0; }
a.cc: In function 'int main()': a.cc:45:32: error: could not convert 'miniumed[now]' from 'VI' {aka 'std::vector<long long int>'} to 'bool' 45 | if(miniumed[now]) continue; | ~~~~~~~~~~~~^ | | | VI {aka std::vector<long long int>}
s220694491
p04003
C++
#include <stdio.h> #include <bits/stdc++.h> using namespace std; typedef long long ll; #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define FILL(a,x) memset(a,x,sizeof(a)) #define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++) #define mp make_pair #define pb push_back #define X first #define Y second #define sz(a) int((a).size()) #define N 100010 #define MAX 30 #define mod 1000000007 #define REP(i,a) for(int i=0;i<a;++i) #define REPP(i,a,b) for(int i=a;i<b;++i) #define all(a) a.begin(),a.end() const ll INF = 1e18+1; unordered_map <pii, int> dis; vector <pii> G[N]; void djikstra(int a) { dis[mp(a,-1)]=0; set < pair <int, pii> > s; int v,i,len,x,y,z,col,add,curr; s.insert(mp(0,mp(a,-1))); while(!s.empty()) { x=(*s.begin()).X; y=(*s.begin()).Y.X; z=(*s.begin()).Y.Y; v=y; s.erase(s.begin()); len=G[v].size(); curr=x; col=z; for(i=0;i<len;i++) { x=G[v][i].X; y=G[v][i].Y; if (y==col) add=0; else add=1; z=dis[mp(x,y)]; if (!z||z>curr+add) { if (z) s.erase(mp(z,mp(x,y))); dis[mp(x,y)]=curr+add; s.insert(mp(curr+add,mp(x,y))); } } } } int main() { int n,m,p,q,c,ans=mod; scanf("%d%d",&n,&m); REP(i,m) { scanf("%d%d%d",&p,&q,&c); p--; q--; G[p].pb(mp(q,c)); G[q].pb(mp(p,c)); } djikstra(0); REP(i,sz(G[n-1])) { if (dis[mp(n-1,G[n-1][i].Y)]) ans=min(ans,dis[mp(n-1,G[n-1][i].Y)]); } if (ans==mod) printf("-1\n"); else printf("%d\n",ans); return 0; }
a.cc:23:26: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 23 | unordered_map <pii, int> dis; | ^~~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:2: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::pair<int, int>, std::pair<const std::pair<int, int>, i
s914965174
p04003
C++
#include<stdio.h> #include<algorithm> #include<map> #include<set> #include<vector> #include<queue> using namespace std; int n,m; map<int,vector<int> > e[111111]; int len[111111]; bool trans[111111]; map<int,set<int> > a[111111]; int q[111111],op,cl; int main(){ memset(len,-1,sizeof(len)); scanf("%d%d",&n,&m); while(m--){ int x,y,z; scanf("%d%d%d",&x,&y,&z); if(x>y)swap(x,y); e[x][z].push_back(y); e[y][z].push_back(x); if(x == 1){ len[y] = 1; a[1][z].insert(y); } } len[1] = 0; trans[1] = true; for(int step=1;;step++){ if(a[step].empty()){ puts("-1"); return 0; } //same color. for(map<int,set<int> >::iterator it = a[step].begin(); it != a[step].end(); it++){ op=cl=0; for(set<int>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++) q[op++]=*it2; int col = it->first; while(cl<op){ int y = q[cl++]; if(!e[y].count(col))continue; for(vector<int>::iterator it2 = e[y][col].begin(); it2 != e[y][col].end(); it2++){ int to = *it2; if(len[to] != -1 && len[to] < step)continue; if(a[step][col].count(to))continue; a[step][col].insert(to); q[op++]=to; len[to]=step; } } } //different color for(map<int,set<int> >::iterator it = a[step].begin(); it != a[step].end(); it++){ for(set<int>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++){ int y = *it2; if(trans[y])continue; for(map<int,vector<int> >::iterator it3 = e[y].begin(); it3 != e[y].end(); it3++) for(vector<int>::iterator it4 = it3->second.begin(); it4 != it3 ->second.end(); it4++){ int to = *it4; if(len[to] != -1 && len[to] <= step)continue; len[to] = step+1; a[step+1][it3->first].insert(to); } } } if(len[n]!=-1){ printf("%d\n",len[n]); return 0; } } }
a.cc: In function 'int main()': a.cc:16:9: error: 'memset' was not declared in this scope 16 | memset(len,-1,sizeof(len)); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include<queue> +++ |+#include <cstring> 7 | using namespace std;
s071934241
p04003
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "<<x<<endl #define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl #define ALL(a) (a).begin(),(a).end() #define CHMIN(a,b) a=min((a),(b)) #define CHMAX(a,b) a=max((a),(b)) // mod const ll MOD = 1000000007ll; #define FIX(a) ((a)%MOD+MOD)%MOD // floating typedef double Real; const Real EPS = 1e-11; #define EQ0(x) (abs(x)<EPS) #define EQ(a,b) (abs(a-b)<EPS) typedef complex<Real> P; int n,m; vector<pii> g[125252]; unordered_map<int,int> typedeg[125252]; unordered_set<int> visited[125252]; int dist[125252]; int main(){ scanf("%d%d",&n,&m); REP(i,m){ int p,q,c; scanf("%d%d%d",&p,&q,&c); --p;--q; g[p].push_back(pii(q,c)); g[q].push_back(pii(p,c)); typedeg[p][c] += 1; typedeg[q][c] += 1; } // -dist,pos,type priority_queue<pair<int,pii>> Q; const int INF = 830252521; REP(i,n)dist[i]=INF; dist[0] = 0; Q.push(make_pair(0,pii(0,-1))); while(!Q.empty()){ pair<int,pii> P = Q.top(); Q.pop(); int d = -P.first; int pos = P.second.first; int type = P.second.second; for(const pii& T:g[pos]){ int to = T.first; int totype = T.second; int ndist = d + (type==totype ? 0 : 1); if(ndist > dist[to])continue; if(ndist == dist[to] && visited[to].count(totype))continue; if(ndist == dist[to] && typedeg[to][totype]==1)continue; // go dist[to] = ndist; visited[to].insert(totype); if(to==n-1){ Q.clear(); break; } Q.push(make_pair(-ndist,pii(to,totype))); } } int ans = dist[n-1]; if(dist[n-1]==INF){ ans = -1; } printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:73:11: error: 'class std::priority_queue<std::pair<int, std::pair<int, int> > >' has no member named 'clear' 73 | Q.clear(); | ^~~~~
s355611996
p04004
C++
4 2 2
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 4 2 2 | ^
s426078804
p04004
C++
#define LOCAL #include <map> #include <unordered_map> #include <unordered_set> #include <set> #include <vector> #include <numeric> #include <algorithm> #include <iostream> #include <string> #include <cstring> #include <sstream> #include <functional> #include <queue> #include <deque> #include <stack> using namespace std; // From Errichto's Youtube stream #define sim template < class c #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c&) { ris; } #endif }; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " using int64 = long long; ///////////////////// // Code starts here// ///////////////////// const int MOD = 1000000007; int N, M, K; vector<int> inv, invfact, pow3, pow2, fact; void add (int & a, int b) { a += b; if (a >= MOD) a -= MOD; } int mul (int a, int b) { return (int64)a * b % MOD; } int Choose (int n, int k) { assert(k <= n); if (!k) return 1; if (n == k) return 1; return mul(fact[n], mul(invfact[k], invfact[n-k])); } inline int power(int a, int b) { int res = 1; while (b > 0) { if (b & 1) { res = mul(res, a); } a = mul(a, a); b >>= 1; } return res; } inline int inverse(int x) { return power(x, MOD - 2); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> N >> M >> K; N--; if (M > K) { swap(M, K); } int result = 0; pow3.resize(N + M + K + 2); pow2 = pow3; fact = pow3; invfact = pow3; pow3[0] = 1; pow2[0] = 1; for (int i = 1; i < pow3.size(); i++) { pow2[i] = mul(pow2[i - 1], 2); pow3[i] = mul(pow3[i - 1], 3); } fact[0] = 1; for (int i = 1; i < fact.size(); i++) { fact[i] = mul(fact[i-1], i); } invfact[N + M + K + 1] = inverse(fact[N + M + K + 1]); for (int i = N + M + K; i >= 0; i--) { invfact[i] = mul(invfact[i + 1], i + 1); } for (int m = 0; m <= M; m++) { for (int k = 0; k <= K; k++) { auto cur = Choose(m + k, k); cur = mul (cur, pow3[M + K - (m + k)]); cur = mul (cur, Choose(N + m + k, N)); add(result, cur); } } // divide by N! cout << result << "\n"; return 0; }
a.cc: In function 'int Choose(int, int)': a.cc:73:5: error: 'assert' was not declared in this scope 73 | assert(k <= n); | ^~~~~~ a.cc:18:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 17 | #include <stack> +++ |+#include <cassert> 18 |
s858178252
p04004
C++
#include <bits/stdc++.h> using namespace std ; const int mod = 1e9 + 7 ; const int N = 900010 ; #define ll long long int n , m , k ; ll fac[ N ] , ifac[ N ] , p[ N ] ; ll mul( ll x , ll y ) { return ( 1ll * x * y ) % mod ; } ll add( ll x , ll y ) { return ( x + y ) % mod ; } ll power( ll a , ll b ) { int ans = 1 , base = a ; while( b ) { if( b&1 ) ans = mul( ans , base ) ; base = mul( base , base ) ; b >>= 1 ; } return ans ; } ll inv( ll x ) { return power( x , mod - 2 ) % mod ; } ll C( ll x , ll y ) { return ( fac[ x ] * ifac[ y ] % mod * ifac[ x - y ] % mod ) % mod ; } int main() { scanf( "%d%d%d" , &n , &m , &k ) ; fac[ 0 ] = 1ll ; p[ 0 ] = 1ll ; for( int i = 1 ; i < N ; i ++ ) { fac[ i ] = fac[ i - 1 ] * i % mod ; p[ i ] = p[ i - 1 ] * 3ll % mod ; } for( int i = 0 ; i < N ; i ++ ) { ifac[ i ] = inv( fac[ i ] ) ; } ll ans = 0 , x = 1ll ; n -- ; for( int i = 0 ; i <= m + k ; i ++ ) { ans = ( ans + C( n + i , n ) * p[ m + k - i ] % mod * x ) % mod ; if( i < k ) x = ( x * 2ll ) % mod ; else if( i < m ) x = ( x * 2ll - C( i , k ) ) % mod ; else x = ( x * 2ll - C( i , k ) - C( i , m ) ) % mod ; } printf( "%lld\n" , add( ans , mod ) ) ; return 0 ; } 满分做法
a.cc:53:1: error: '\U00006ee1\U00005206\U0000505a\U00006cd5' does not name a type 53 | 满分做法 | ^~~~~~~~
s215145590
p04004
C++
#include<bits/stdc++.h> #define N 300005 #define mod 1000000007 #define ll long long using namespace std; ll up,n,m,k; ll ans=0,fac[N*3],ifac[N*3],mul[N*3]; inline ll calc(int a,int b){return fac[a]*ifac[b]%mod*ifac[a-b]%mod;} inline ll ksm(ll x,int p){ ll ret=1; while(p){ if(p&1)ret=ret*x%mod; x=x*x%mod,p>>=1; } return ret; } int main(){ cin>>n>>m>>k,up=n+m+k,fac[0]=mul[0]=ifac[1]=ifac[0]=1; for(ll i=2;i<=up;++i)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod; for(ll i=1;i<=up;++i)mul[i]=mul[i-1]*3%mod,(ifac[i]*=ifac[i-1])%=mod,fac[i]=fac[i-1]*i%mod; if(m<k)m^=k,k^=m,m^=k; for(ll i=0,j=1;i<=m+k;++i){ (ans+=calc(n-1+i,n-1)*mul[m+k-i]%mod*j%mod)%=mod; if(i<k)(j<<=1)%=mod; else if(i>=m)(j+=j-calc(i,k)-calc(i,i-m))%=mod; else (j+=j-calc(i,k))%=mod; } cout<<(ans+mod)%mod; return 0; } --------------------- 本文来自 dreaming__ldx 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/dreaming__ldx/article/details/82778499?utm_source=copy
a.cc:32:1: error: expected unqualified-id before '--' token 32 | --------------------- | ^~
s984304477
p04004
C++
考虑后面的求和部分。它显然分成三段。形式分别是∑Mi=0CiM;∑ki=0CkM;∑ki=tCkM 如果我们知道M=i-1时的总和,要推到M=i时的总和。根据杨辉三角公式,第一种情况直接乘2,第二种是乘2再减掉Cki−1,第三种是乘2减掉Cki−1和Ct−1i−1 复杂度是线性的 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N=9e5+5,mo=1e9+7; typedef long long LL; int n,m,K,ans,Fac[N],Inv[N],p[N]; int C(int n,int m) { return (LL)Fac[n]*Inv[m]%mo*Inv[n-m]%mo; } int main() { p[0]=Fac[0]=Inv[0]=Fac[1]=Inv[1]=1; p[1]=3; for (int i=2;i<N;i++) Inv[i]=(LL)Inv[mo%i]*(mo-mo/i)%mo; for (int i=2;i<N;i++) { p[i]=p[i-1]*3ll%mo; Fac[i]=(LL)Fac[i-1]*i%mo; Inv[i]=(LL)Inv[i-1]*Inv[i]%mo; } scanf("%d%d%d",&n,&m,&K); n--; if (m<K) swap(m,K); for (int i=0,j=1;i<=m+K;i++) { ans=(ans+(LL)C(n+i,n)*p[m+K-i]%mo*j)%mo; if (i<K) j=j*2%mo; else if (i>=m) j=(j*2ll-C(i,K)-C(i,i-m))%mo; else j=(j*2ll-C(i,K))%mo; } if (ans<0) ans+=mo; printf("%d\n",ans); return 0; }
a.cc:2:1: error: extended character 。 is not valid in an identifier 2 | 考虑后面的求和部分。它显然分成三段。形式分别是∑Mi=0CiM;∑ki=0CkM;∑ki=tCkM | ^ a.cc:2:1: error: extended character 。 is not valid in an identifier a.cc:2:1: error: extended character ∑ is not valid in an identifier a.cc:2:51: error: extended character ∑ is not valid in an identifier 2 | 考虑后面的求和部分。它显然分成三段。形式分别是∑Mi=0CiM;∑ki=0CkM;∑ki=tCkM | ^ a.cc:2:61: error: extended character ∑ is not valid in an identifier 2 | 考虑后面的求和部分。它显然分成三段。形式分别是∑Mi=0CiM;∑ki=0CkM;∑ki=tCkM | ^ a.cc:3:36: error: extended character 。 is not valid in an identifier 3 | 如果我们知道M=i-1时的总和,要推到M=i时的总和。根据杨辉三角公式,第一种情况直接乘2,第二种是乘2再减掉Cki−1,第三种是乘2减掉Cki−1和Ct−1i−1 | ^ a.cc:3:36: error: extended character − is not valid in an identifier a.cc:3:36: error: extended character − is not valid in an identifier a.cc:3:36: error: extended character − is not valid in an identifier a.cc:3:36: error: extended character − is not valid in an identifier a.cc:2:1: error: '\U00008003\U00008651\U0000540e\U00009762\U00007684\U00006c42\U0000548c\U000090e8\U00005206\U00003002\U00005b83\U0000663e\U00007136\U00005206\U00006210\U00004e09\U00006bb5\U00003002\U00005f62\U00005f0f\U00005206\U0000522b\U0000662f\U00002211Mi' does not name a type 2 | 考虑后面的求和部分。它显然分成三段。形式分别是∑Mi=0CiM;∑ki=0CkM;∑ki=tCkM | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from a.cc:10: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdio.h:34, from /usr/include/c++/14/cstdio:42, from a.cc:8: /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/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /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/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /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/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /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/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:65: /usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type 125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' +++ |+#include <cstddef> 1 | // T
s576977533
p04004
C++
#include <bits/stdc++.h> #define endl '\n' using namespace std; template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; } template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; } const int MAXN = (1 << 21); const int mod = (int)1e9 + 7; const double PI = acos(-1.0); const int BK = 100; const int CK = 5; inline void addmod(int& x, int y, int mod) { (x += y) >= mod && (x -= mod); } inline int mulmod(int x, int y, int mod) { return x * 1ll * y % mod; } struct complex_base { double x, y; complex_base(double _x = 0, double _y = 0) { x = _x; y = _y; } friend complex_base operator-(const complex_base &a, const complex_base &b) { return complex_base(a.x - b.x, a.y - b.y); } friend complex_base operator+(const complex_base &a, const complex_base &b) { return complex_base(a.x + b.x, a.y + b.y); } friend complex_base operator*(const complex_base &a, const complex_base &b) { return complex_base(a.x * b.x - a.y * b.y, a.y * b.x + b.y * a.x); } friend void operator/=(complex_base &a, const double &P) { a.x /= P; a.y /= P; } }; int bit_rev[MAXN]; void fft(complex_base *a, int lg) { int n = (1 << lg); for(int i = 1; i < n; i++) { bit_rev[i] = (bit_rev[i >> 1] >> 1) | ((i & 1) << (lg - 1)); if(bit_rev[i] < i) swap(a[i], a[bit_rev[i]]); } for(int len = 2; len <= n; len <<= 1) { long double ang = 2 * PI / len; complex_base w(1, 0), wn(cosl(ang), sinl(ang)); for(int j = 0; j < (len >> 1); j++, w = w * wn) for(int i = 0; i < n; i += len) { complex_base u = a[i + j], v = w * a[i + j + (len >> 1)]; a[i + j] = u + v; a[i + j + (len >> 1)] = u - v; } } } void inv_fft(complex_base *a, int lg) { int n = (1 << lg); for(int i = 1; i < n; i++) { bit_rev[i] = (bit_rev[i >> 1] >> 1) | ((i & 1) << (lg - 1)); if(bit_rev[i] < i) swap(a[i], a[bit_rev[i]]); } for(int len = 2; len <= n; len <<= 1) { long double ang = -2 * PI / len; complex_base w(1, 0), wn(cosl(ang), sinl(ang)); for(int j = 0; j < (len >> 1); j++, w = w * wn) for(int i = 0; i < n; i += len) { complex_base u = a[i + j], v = w * a[i + j + (len >> 1)]; a[i + j] = u + v; a[i + j + (len >> 1)] = u - v; } } for(int i = 0; i < n; i++) a[i] /= n; } complex_base A[MAXN], B[MAXN]; vector<int> mult(const vector<int> &a, const vector<int> &b) { if(a.size() * b.size() <= 128) { vector<int> ans(a.size() + b.size(), 0); for(int i = 0; i < (int)a.size(); i++) for(int j = 0; j < (int)b.size(); j++) ans[i + j] = (ans[i + j] + a[i] * 1ll * b[j]) % mod; return ans; } int lg = 0; while((1 << lg) < (int)(a.size() + b.size())) ++lg; for(int i = 0; i < (1 << lg); i++) A[i] = B[i] = complex_base(0, 0); for(int i = 0; i < (int)a.size(); i++) A[i] = complex_base(a[i], 0); for(int i = 0; i < (int)b.size(); i++) B[i] = complex_base(b[i], 0); fft(A, lg); fft(B, lg); for(int i = 0; i < (1 << lg); i++) A[i] = A[i] * B[i]; inv_fft(A, lg); vector<int> ans(a.size() + b.size(), 0); for(int i = 0; i < (int)ans.size(); i++) ans[i] = (int64_t)(A[i].x + 0.5) % mod; return ans; } vector<complex_base> to_fft(const vector<complex_base> &a, int lg) { for(int i = 0; i < (1 << lg); i++) A[i] = complex_base(0, 0); for(int i = 0; i < (int)a.size(); i++) A[i] = a[i]; fft(A, lg); vector<complex_base> ret(1 << lg, 0); for(int i = 0; i < (1 << lg); i++) ret[i] = A[i]; return ret; } vector<complex_base> to_inv_fft(const vector<complex_base> &a, int lg) { for(int i = 0; i < (1 << lg); i++) A[i] = complex_base(0, 0); for(int i = 0; i < (int)a.size(); i++) A[i] = a[i]; inv_fft(A, lg); vector<complex_base> ret(1 << lg, 0); for(int i = 0; i < (1 << lg); i++) ret[i] = A[i]; return ret; } vector<int> mult_mod(const vector<int> &a, const vector<int> &b) { /// Thanks pavel.savchenkov // a = a0 + sqrt(MOD) * a1 // a = a0 + base * a1 int base = (int)sqrtl(mod); vector<int> a0(a.size()), a1(a.size()); for(int i = 0; i < (int)a.size(); i++) { a0[i] = a[i] % base; a1[i] = a[i] / base; } vector<int> b0(b.size()), b1(b.size()); for(int i = 0; i < (int)b.size(); i++) { b0[i] = b[i] % base; b1[i] = b[i] / base; } vector<int> a01 = a0; for(int i = 0; i < (int)a.size(); i++) addmod(a01[i], a1[i], mod); vector<int> b01 = b0; for(int i = 0; i < (int)b.size(); i++) addmod(b01[i], b1[i], mod); vector<int> C = mult(a01, b01); // 1 vector<int> a0b0 = mult(a0, b0); // 2 vector<int> a1b1 = mult(a1, b1); // 3 vector<int> mid = C; for(int i = 0; i < (int)mid.size(); i++) { addmod(mid[i], -a0b0[i] + mod, mod); addmod(mid[i], -a1b1[i] + mod, mod); } vector<int> res = a0b0; for(int i = 0; i < (int)res.size(); i++) addmod(res[i], mulmod(base, mid[i], mod), mod); base = mulmod(base, base, mod); for(int i = 0; i < (int)res.size(); i++) addmod(res[i], mulmod(base, a1b1[i], mod), mod); return res; } #define mp make_pair #define sz(C) ((int) (C).size()) #define forn(i, n) for (int i = 0; i < (int) n; ++i) typedef vector <int> vi; using ld = double; using ll = int64_t; const ll MOD = mod; namespace FFT { struct cd { ld a, b; cd(ld a, ld b) : a(a), b(b) {} cd(ld x = 0) : a(x), b(0) {} ld real() const { return a; } void operator += (const cd& other) { a += other.a; b += other.b; } void operator -= (const cd& other) { a -= other.a; b -= other.b; } void operator *= (const cd& other) { tie(a, b) = mp(a * other.a - b * other.b, a * other.b + b * other.a); } friend cd operator * (const cd& x, const cd& y) { cd r = x; r *= y; return r; } friend cd operator + (const cd& x, const cd& y) { cd r = x; r += y; return r; } friend cd operator - (const cd& x, const cd& y) { cd r = x; r -= y; return r; } void operator /= (ld c) { a /= c; b /= c; } }; typedef vector<cd> vcd; const int LOG = 20; const int N = 1 << LOG; int rev[N]; cd root_[N]; inline cd root(int k, int n) { return root_[k * (N / n)]; } void precalc() { rev[0] = 0; int hb = -1; for (int i = 1; i < N; ++i) { if ((i & (i - 1)) == 0) { ++hb; } rev[i] = rev[i ^ (1 << hb)] | (1 << (LOG - hb - 1)); } forn(i, N) { ld ang = PI * i * 2.0 / N; root_[i] = cd(cosl(ang), sinl(ang)); } } void fft_rec(cd* a, int n) { if (n == 1) { return; } fft_rec(a, n / 2); fft_rec(a + n / 2, n / 2); forn(k, n / 2) { cd w = root(k, n); cd x = a[k]; cd y = w * a[k + n / 2]; a[k] = x + y; a[k + n / 2] = x - y; } } void fft(vcd& a) { int n = sz(a); vcd na(n, cd(0, 0)); forn(i, n) na[i] = a[rev[i]]; na.swap(a); fft_rec(&a[0], n); } void fft_inv(vcd& a) { fft(a); int n = sz(a); reverse(a.begin() + 1, a.end()); forn(i, n) { a[i] /= n; } } vi mult(const vi& a, const vi& b) { // TimeStamp t("mult"); vcd A(N, cd(0, 0)); vcd B(N, cd(0, 0)); forn(i, sz(a)) A[i] = a[i]; forn(i, sz(b)) B[i] = b[i]; fft(A); fft(B); forn(i, N) A[i] *= B[i]; fft_inv(A); vi c(N, 0); forn(i, N) c[i] = ((ll) (A[i].real() + 0.5)) % MOD; return c; } vi multmod(const vi& a, const vi& b) { // a = a0 + sqrt(MOD) * a1 // a = a0 + base * a1 int base = (int) sqrtl(MOD); vi a0(sz(a)), a1(sz(a)); forn(i, sz(a)) { a0[i] = a[i] % base; a1[i] = a[i] / base; assert(a[i] == a0[i] + base * a1[i]); } vi b0(sz(b)), b1(sz(b)); forn(i, sz(b)) { b0[i] = b[i] % base; b1[i] = b[i] / base; assert(b[i] == b0[i] + base * b1[i]); } vi a01 = a0; forn(i, sz(a)) { addmod(a01[i], a1[i], MOD); } vi b01 = b0; forn(i, sz(b)) { addmod(b01[i], b1[i], MOD); } vi C = mult(a01, b01); // 1 vi a0b0 = mult(a0, b0); // 2 vi a1b1 = mult(a1, b1); // 3 vi mid = C; forn(i, N) { addmod(mid[i], -a0b0[i] + MOD, MOD); addmod(mid[i], -a1b1[i] + MOD, MOD); } vi res = a0b0; forn(i, N) { addmod(res[i], mulmod(base, mid[i], MOD), MOD); } base = mulmod(base, base, MOD); forn(i, N) { addmod(res[i], mulmod(base, a1b1[i], MOD), MOD); } return res; } }; int n, m, k; void read() { cin >> n >> m >> k; } vector<int> p1, p2, pw3; int pw(int x, int p) { int ret = 1; while(p) { if(p & 1) ret = (ret * 1ll * x) % mod; x = (x * 1ll * x) % mod; p >>= 1; } return ret; } int fact[MAXN], inv_fact[MAXN]; int comb(int n, int k) { if(n < 0 || k < 0 || n < k) return 0; return (((fact[n] * 1ll * inv_fact[n - k]) % mod) * 1ll * inv_fact[k]) % mod; } /* SUM C(n + i - 1, i) * C(n + i - 1 + j, j) */ /* SUM C(n + i - 1, i) * fact[n + i - 1 + j] / (fact[j] * fact[n + i - 1]) */ void solve() { pw3.assign(n + m + k + 1, 0); p1.assign(m + 1, 0); p2.assign(k + 1, 0); pw3[0] = 1; for(int i = 1; i <= m + k + n; i++) pw3[i] = (3ll * pw3[i - 1]) % mod; fact[0] = 1; for(int i = 1; i <= m + k + n; i++) fact[i] = (fact[i - 1] * 1ll * i) % mod; inv_fact[m + k + n] = pw(fact[m + k + n], mod - 2); for(int i = n + k + m - 1; i >= 0; i--) inv_fact[i] = (inv_fact[i + 1] * 1ll * (i + 1)) % mod; for(int i = 0; i <= m; i++) p1[i] = (comb(n + i - 1, i) * 1ll * inv_fact[n + i - 1]) % mod; for(int i = 0; i <= k; i++) p2[i] = inv_fact[i]; vector<int> ret = mult_mod(p1, p2); int answer = 0; for(int i = 0; i < (int)ret.size(); i++) { if(m + k - i < 0) break; int curr = (ret[i] * 1ll * pw3[m + k - i]) % mod; curr = (curr * 1ll * fact[n - 1 + i]) % mod; addmod(answer, curr, mod); } cout << answer << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); read(); solve(); return 0; } v
a.cc:453:1: error: 'v' does not name a type; did you mean 'vi'? 453 | v | ^ | vi
s206346547
p04004
C++
#include<iostream> #include<algorithm> #include<vector> using namespace std; #define fi(a,b) for(int i=a;i<b;++i) typedef long long ll; /////////////////// int const N = 3e3 + 41; int const MOD = 1e9 + 7; int n, m, k; int f[N], invf[N]; int th[N]; int ans; void add(int &a, int b){ a += b; while(a >= MOD) a -= MOD; while(a < 0) a += MOD; } int mul(int a, int b){ return (ll) a * b % MOD; } int bp(int x, int d){ int res = 1; while(d){ if(d&1) res = mul(res, x); d >>= 1; x = mul(x, x); } return res; } int inv(int x){ return bp(x, MOD-2); } void init(){ f[0] = 1; fi(1, N) f[i] = mul(f[i-1], i); fi(0, N) invf[i] = inv(f[i]); th[0] = 1; fi(1, N) th[i] = mul(th[i-1], 3); } int getc(int n, int k){ if(k > n) return 0; int res = f[n]; res = mul(res, invf[k]); res = mul(res, invf[n-k]); return res; } int dg[N]; int getg(int x){ if(dg[x] != -1) return dg[x]; int res = 0; fi(0, k+1){ int y = x - i; if(y > m) continue; int v = getc(x, i); add(res, v); } dg[x] = res; return res; } void solve(){ int x = n + m + k; memset(dg, 255, sizeof(dg)); fi(1, x+1){ int f = getc(i-1, n-1); int g = getg(i-n); int t = th[x-i]; add(ans, mul(f, mul(g, t))); } } int main(){ #ifdef _DEBUG freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif init(); scanf("%d %d %d",&n,&m,&k); solve(); printf("%d\n",ans); return 0; }
a.cc: In function 'void solve()': a.cc:76:9: error: 'memset' was not declared in this scope 76 | memset(dg, 255, sizeof(dg)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<vector> +++ |+#include <cstring> 4 |
s634534403
p04004
C++
#include<bits/stdc++.h> using namespace std; int N, M, K, v[600009]; const int mod = 1e9 + 7; int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;} int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;} int mul (int x, int y) {return 1LL * x * y % mod;} void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;} int power (int a, int b) { int p = 1; for (int i=0; (1<<i) <= b; i++) { if (b & (1 << i)) p = mul (p, a); a = mul (a, a); } return p; } int fac[1000009], inv[1000009], p3[1000009]; void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i); inv[lim] = power (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);} int comb (int N, int K){int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;} int main () { /freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d %d %d", &N, &M, &K), Prec (900003), p3[0] = 1; for (int i=1; i<=900000; i++) p3[i] = add (add (p3[i - 1], p3[i - 1]), p3[i - 1]); /*for (int i=0; i<=M; i++) for (int j=0; j<=K; j++) adto (v[i + j], comb (i + j, i));*/ /* sa consideram un dreptunghi cu un colt in (0, 0) si unul in (M, K) pentru fiecare diagonala secundara, vrem sa stim numarul de drumuri care duc in diagonala aia */ v[0] = 1; if (M > K) swap (M, K); ///M <= K for (int i=1; i<=M + K; i++) { v[i] = add (v[i - 1], v[i - 1]); if (i > M) v[i] = subtract (v[i], comb (i - 1, M)); if (i > K) v[i] = subtract (v[i], comb (i - 1, K)); } int ans = 0; for (int i=0; i<=M + K; i++) { v[i] = mul (v[i], p3[M + K - i]); adto (ans, mul (v[i], comb (i + N - 1, N - 1))); } printf ("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:31:1: error: expected primary-expression before '/' token 31 | /freopen ("input", "r", stdin); | ^
s985454942
p04004
C++
あせfvf
a.cc:1:1: error: '\U00003042\U0000305bfvf' does not name a type 1 | あせfvf | ^~~~~~~
s699575780
p04004
Java
#include<bits/stdc++.h> using namespace std; long long FACT[1000000]; long long IFACT[1000000]; static int MOD = 1000000007; static int mod = MOD; int modPow(long a, long b) { if(b == 0) return 1 % MOD; if(b == 1) return (int) (a % MOD); if(b % 2 == 0) { long ret = modPow(a % MOD,b / 2) % MOD; return (int)((ret * ret) % MOD); } else { long ret = (a * (long)modPow(a % MOD,b-1)) % MOD; return (int)(ret % MOD); } } long long C(int n, int r) { if(n < 0 || r < 0 || r > n)return 0; if(r > n / 2)r = n - r; return FACT[n]*IFACT[n-r]%mod*IFACT[r]%mod; } long long INV(long v) { return modPow(v, MOD - 2); } int main() { int N,M,K,n; cin >> N >> M >> K; n = N + M + K; FACT[0] = 1; IFACT[0] = 1; for(int i = 1;i <= n;i++){ FACT[i] = FACT[i-1] * i % mod; IFACT[i] = INV(FACT[i]); } long long ans = 0; long long hh = 0; for(int i = N; i <= N + M + K; i++) { int retA = modPow(3,N + M + K - i); int retB = (int)C(i-1,N-1); long retC = 0; retC = (retC + modPow(2,i - N)) % MOD; hh = hh * 2 % MOD; if (i - N > M) hh = (hh + C(M + i - N - M - 1, i - N - M - 1)) % MOD; if (i - N > K) hh = (hh + C(K + i - N - K - 1, i - N - K - 1)) % MOD; retC = (retC - hh) % MOD; long ansA = ((long)(retA) * (long)(retB)) % MOD; ansA *= retC % MOD; ansA %= MOD; ans += ansA; ans %= MOD; } cout << ans << endl; }
Main.java:1: error: illegal character: '#' #include<bits/stdc++.h> ^ Main.java:1: error: class, interface, enum, or record expected #include<bits/stdc++.h> ^ Main.java:4: error: class, interface, enum, or record expected long long FACT[1000000]; ^ Main.java:5: error: class, interface, enum, or record expected long long IFACT[1000000]; ^ Main.java:7: error: unnamed classes are a preview feature and are disabled by default. static int MOD = 1000000007; ^ (use --enable-preview to enable unnamed classes) Main.java:25: error: class, interface, enum, or record expected long long C(int n, int r) ^ Main.java:28: error: class, interface, enum, or record expected if(r > n / 2)r = n - r; ^ Main.java:29: error: class, interface, enum, or record expected return FACT[n]*IFACT[n-r]%mod*IFACT[r]%mod; ^ Main.java:30: error: class, interface, enum, or record expected } ^ Main.java:34: error: class, interface, enum, or record expected } ^ Main.java:40: error: class, interface, enum, or record expected cin >> N >> M >> K; ^ Main.java:41: error: class, interface, enum, or record expected n = N + M + K; ^ Main.java:43: error: class, interface, enum, or record expected FACT[0] = 1; ^ Main.java:44: error: class, interface, enum, or record expected IFACT[0] = 1; ^ Main.java:45: error: class, interface, enum, or record expected for(int i = 1;i <= n;i++){ ^ Main.java:45: error: class, interface, enum, or record expected for(int i = 1;i <= n;i++){ ^ Main.java:45: error: class, interface, enum, or record expected for(int i = 1;i <= n;i++){ ^ Main.java:47: error: class, interface, enum, or record expected IFACT[i] = INV(FACT[i]); ^ Main.java:48: error: class, interface, enum, or record expected } ^ Main.java:50: error: class, interface, enum, or record expected long long hh = 0; ^ Main.java:51: error: class, interface, enum, or record expected for(int i = N; i <= N + M + K; i++) { ^ Main.java:51: error: class, interface, enum, or record expected for(int i = N; i <= N + M + K; i++) { ^ Main.java:51: error: class, interface, enum, or record expected for(int i = N; i <= N + M + K; i++) { ^ Main.java:56: error: class, interface, enum, or record expected retC = (retC + modPow(2,i - N)) % MOD; ^ Main.java:57: error: class, interface, enum, or record expected hh = hh * 2 % MOD; ^ Main.java:58: error: class, interface, enum, or record expected if (i - N > M) hh = (hh + C(M + i - N - M - 1, i - N - M - 1)) % MOD; ^ Main.java:59: error: class, interface, enum, or record expected if (i - N > K) hh = (hh + C(K + i - N - K - 1, i - N - K - 1)) % MOD; ^ Main.java:60: error: class, interface, enum, or record expected retC = (retC - hh) % MOD; ^ Main.java:63: error: class, interface, enum, or record expected ansA *= retC % MOD; ^ Main.java:64: error: class, interface, enum, or record expected ansA %= MOD; ^ Main.java:65: error: class, interface, enum, or record expected ans += ansA; ^ Main.java:66: error: class, interface, enum, or record expected ans %= MOD; ^ Main.java:67: error: class, interface, enum, or record expected } ^ Main.java:69: error: class, interface, enum, or record expected } ^ 34 errors
s490275929
p04004
Java
import java.awt.geom.Point2D; import java.io.*; import java.math.*; import java.util.*; import java.util.Map.*; public class Main { public static long C(int n, int r) { if(n < 0 || r < 0 || r > n)return 0; if(r > n / 2)r = n - r; return FACT[n]*IFACT[n-r]%mod*IFACT[r]%mod; } long extGcd() static long[] FACT, IFACT; static long get_gcd(long n, long m) { if (n < m) { long tmp = n; n = m; m = tmp; } while (m != 0) { long tmp = n; n = m; m = tmp; m %= n; } return n; } public static long modinv(long x, long m) { long s, t; s = get_gcd(x, m); return (m+s) % m; } static int MOD = 1000000007; static int mod = MOD; public static void main(String[] args) { int n = 900000; FACT = new long[n+1]; IFACT = new long[n+1]; FACT[0] = 1; IFACT[0] = 1; for(int i = 1;i <= n;i++){ FACT[i] = FACT[i-1] * i % mod; IFACT[i] = new BigInteger(String.valueOf(FACT[i])).modInverse(new BigInteger(String.valueOf(mod))).longValue(); } Scanner sc = new Scanner(System.in); PrintStream out = new PrintStream(System.out); int N = sc.nextInt(); int M = sc.nextInt(); int K = sc.nextInt(); long ans = 0; for(int i = N; i <= N + M + K; i++) { int retA = modPow(3,N + M + K - i); int retB = (int)C(i-1,N-1); int kMax = Math.max(0, i - N-K); int kMin = Math.min(i - N, M); long sum = 0; for(int k = kMax; k <= kMin; k++) { sum += (int)C(i - N, k) % MOD; sum %= MOD; } long ansA = ((long)(retA) * (long)(retB)) % MOD; ansA *= sum % MOD; ansA %= MOD; ans += ansA; ans %= MOD; } System.out.println(ans); } public static int modPow(int a, int b) { if(b == 0) return 1 % MOD; if(b == 1) return a % MOD; if(b % 2 == 0) { long ret = modPow(a % MOD,b / 2) % MOD; return (int)((ret * ret) % MOD); } else { long ret = (a * (long)modPow(a % MOD,b-1)) % MOD; return (int)(ret % MOD); } } public static int comb(int n, int k) { if(k == 0) return 1; long AA = 1; for(int i = 0; i < k; i++) { AA *= (long)n - i; AA %= MOD; } for(int i = 1; i <= k; i++) { AA *= new BigInteger(String.valueOf(i)).modInverse(new BigInteger(String.valueOf(MOD))).longValue(); AA %= MOD; } return (int)(AA % MOD); } }
Main.java:17: error: ';' expected long extGcd() ^ 1 error
s259343305
p04004
Java
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class D3 { static InputStream is; static PrintWriter out; static String INPUT = ""; static void solve() { int n = ni(), m = ni(), K = ni(); // (t-1)!/(n-1)!b!c!*3^(n+m+K-t) // b<=m, c<=K int mod = 1000000007; int[][] fif = enumFIF(400000, mod); long[] ib = new long[m+1]; for(int i = 0;i <= m;i++)ib[i] = fif[1][i]; long[] ic = new long[K+1]; for(int i = 0;i <= K;i++)ic[i] = fif[1][i]; long[] is = convolute(ib, ic, 3, mod); long ret = 0; for(int t = n;t <= n+m+K;t++){ ret = ret * 3 + (long)fif[0][t-1]*is[t-n]; ret %= mod; } ret = ret * fif[1][n-1] % mod; out.println(ret); } public static final int[] NTTPrimes = {1053818881, 1051721729, 1045430273, 1012924417, 1007681537, 1004535809, 998244353, 985661441, 976224257, 975175681}; public static final int[] NTTPrimitiveRoots = {7, 6, 3, 5, 3, 3, 3, 3, 3, 17}; // public static final int[] NTTPrimes = {1012924417, 1004535809, 998244353, 985661441, 975175681, 962592769, 950009857, 943718401, 935329793, 924844033}; // public static final int[] NTTPrimitiveRoots = {5, 3, 3, 3, 17, 7, 7, 7, 3, 5}; public static long[] convoluteSimply(long[] a, long[] b, int P, int g) { int m = Math.max(2, Integer.highestOneBit(Math.max(a.length, b.length)-1)<<2); long[] fa = nttmb(a, m, false, P, g); long[] fb = a == b ? fa : nttmb(b, m, false, P, g); for(int i = 0;i < m;i++){ fa[i] = fa[i]*fb[i]%P; } return nttmb(fa, m, true, P, g); } public static long[] convolute(long[] a, long[] b) { int USE = 2; int m = Math.max(2, Integer.highestOneBit(Math.max(a.length, b.length)-1)<<2); long[][] fs = new long[USE][]; for(int k = 0;k < USE;k++){ int P = NTTPrimes[k], g = NTTPrimitiveRoots[k]; long[] fa = nttmb(a, m, false, P, g); long[] fb = a == b ? fa : nttmb(b, m, false, P, g); for(int i = 0;i < m;i++){ fa[i] = fa[i]*fb[i]%P; } fs[k] = nttmb(fa, m, true, P, g); } int[] mods = Arrays.copyOf(NTTPrimes, USE); long[] gammas = garnerPrepare(mods); int[] buf = new int[USE]; for(int i = 0;i < fs[0].length;i++){ for(int j = 0;j < USE;j++)buf[j] = (int)fs[j][i]; long[] res = garnerBatch(buf, mods, gammas); long ret = 0; for(int j = res.length-1;j >= 0;j--)ret = ret * mods[j] + res[j]; fs[0][i] = ret; } return fs[0]; } public static long[] convolute(long[] a, long[] b, int USE, int mod) { int m = Math.max(2, Integer.highestOneBit(Math.max(a.length, b.length)-1)<<2); long[][] fs = new long[USE][]; for(int k = 0;k < USE;k++){ int P = NTTPrimes[k], g = NTTPrimitiveRoots[k]; long[] fa = nttmb(a, m, false, P, g); long[] fb = a == b ? fa : nttmb(b, m, false, P, g); for(int i = 0;i < m;i++){ fa[i] = fa[i]*fb[i]%P; } fs[k] = nttmb(fa, m, true, P, g); } int[] mods = Arrays.copyOf(NTTPrimes, USE); long[] gammas = garnerPrepare(mods); int[] buf = new int[USE]; for(int i = 0;i < fs[0].length;i++){ for(int j = 0;j < USE;j++)buf[j] = (int)fs[j][i]; long[] res = garnerBatch(buf, mods, gammas); long ret = 0; for(int j = res.length-1;j >= 0;j--)ret = (ret * mods[j] + res[j]) % mod; fs[0][i] = ret; } return fs[0]; } // static int[] wws = new int[270000]; // outer faster // Modifed Montgomery + Barrett private static long[] nttmb(long[] src, int n, boolean inverse, int P, int g) { long[] dst = Arrays.copyOf(src, n); int h = Integer.numberOfTrailingZeros(n); long K = Integer.highestOneBit(P)<<1; int H = Long.numberOfTrailingZeros(K)*2; long M = K*K/P; int[] wws = new int[1<<h-1]; long dw = inverse ? pow(g, P-1-(P-1)/n, P) : pow(g, (P-1)/n, P); long w = (1L<<32)%P; for(int k = 0;k < 1<<h-1;k++){ wws[k] = (int)w; w = modh(w*dw, M, H, P); } long J = invl(P, 1L<<32); for(int i = 0;i < h;i++){ for(int j = 0;j < 1<<i;j++){ for(int k = 0, s = j<<h-i, t = s|1<<h-i-1;k < 1<<h-i-1;k++,s++,t++){ long u = (dst[s] - dst[t] + 2*P)*wws[k]; dst[s] += dst[t]; if(dst[s] >= 2*P)dst[s] -= 2*P; // long Q = (u&(1L<<32)-1)*J&(1L<<32)-1; long Q = (u<<32)*J>>>32; dst[t] = (u>>>32)-(Q*P>>>32)+P; } } if(i < h-1){ for(int k = 0;k < 1<<h-i-2;k++)wws[k] = wws[k*2]; } } for(int i = 0;i < n;i++){ if(dst[i] >= P)dst[i] -= P; } for(int i = 0;i < n;i++){ int rev = Integer.reverse(i)>>>-h; if(i < rev){ long d = dst[i]; dst[i] = dst[rev]; dst[rev] = d; } } if(inverse){ long in = invl(n, P); for(int i = 0;i < n;i++)dst[i] = modh(dst[i]*in, M, H, P); } return dst; } // Modified Shoup + Barrett private static long[] nttsb(long[] src, int n, boolean inverse, int P, int g) { long[] dst = Arrays.copyOf(src, n); int h = Integer.numberOfTrailingZeros(n); long K = Integer.highestOneBit(P)<<1; int H = Long.numberOfTrailingZeros(K)*2; long M = K*K/P; long dw = inverse ? pow(g, P-1-(P-1)/n, P) : pow(g, (P-1)/n, P); long[] wws = new long[1<<h-1]; long[] ws = new long[1<<h-1]; long w = 1; for(int k = 0;k < 1<<h-1;k++){ wws[k] = (w<<32)/P; ws[k] = w; w = modh(w*dw, M, H, P); } for(int i = 0;i < h;i++){ for(int j = 0;j < 1<<i;j++){ for(int k = 0, s = j<<h-i, t = s|1<<h-i-1;k < 1<<h-i-1;k++,s++,t++){ long ndsts = dst[s] + dst[t]; if(ndsts >= 2*P)ndsts -= 2*P; long T = dst[s] - dst[t] + 2*P; long Q = wws[k]*T>>>32; dst[s] = ndsts; dst[t] = ws[k]*T-Q*P&(1L<<32)-1; } } // dw = dw * dw % P; if(i < h-1){ for(int k = 0;k < 1<<h-i-2;k++){ wws[k] = wws[k*2]; ws[k] = ws[k*2]; } } } for(int i = 0;i < n;i++){ if(dst[i] >= P)dst[i] -= P; } for(int i = 0;i < n;i++){ int rev = Integer.reverse(i)>>>-h; if(i < rev){ long d = dst[i]; dst[i] = dst[rev]; dst[rev] = d; } } if(inverse){ long in = invl(n, P); for(int i = 0;i < n;i++){ dst[i] = modh(dst[i] * in, M, H, P); } } return dst; } static final long mask = (1L<<31)-1; public static long modh(long a, long M, int h, int mod) { long r = a-((M*(a&mask)>>>31)+M*(a>>>31)>>>h-31)*mod; return r < mod ? r : r-mod; } private static long[] garnerPrepare(int[] m) { int n = m.length; assert n == m.length; if(n == 0)return new long[0]; long[] gamma = new long[n]; for(int k = 1;k < n;k++){ long prod = 1; for(int i = 0;i < k;i++){ prod = prod * m[i] % m[k]; } gamma[k] = invl(prod, m[k]); } return gamma; } private static long[] garnerBatch(int[] u, int[] m, long[] gamma) { int n = u.length; assert n == m.length; long[] v = new long[n]; v[0] = u[0]; for(int k = 1;k < n;k++){ long temp = v[k-1]; for(int j = k-2;j >= 0;j--){ temp = (temp * m[j] + v[j]) % m[k]; } v[k] = (u[k] - temp) * gamma[k] % m[k]; if(v[k] < 0)v[k] += m[k]; } return v; } private static long pow(long a, long n, long mod) { // a %= mod; long ret = 1; int x = 63 - Long.numberOfLeadingZeros(n); for (; x >= 0; x--) { ret = ret * ret % mod; if (n << 63 - x < 0) ret = ret * a % mod; } return ret; } private static long invl(long a, long mod) { long b = mod; long p = 1, q = 0; while (b > 0) { long c = a / b; long d; d = a; a = b; b = d % b; d = p; p = q; q = d - c * q; } return p < 0 ? p + mod : p; } public static int[][] enumFIF(int n, int mod) { int[] f = new int[n + 1]; int[] invf = new int[n + 1]; f[0] = 1; for (int i = 1; i <= n; i++) { f[i] = (int) ((long) f[i - 1] * i % mod); } long a = f[n]; long b = mod; long p = 1, q = 0; while (b > 0) { long c = a / b; long d; d = a; a = b; b = d % b; d = p; p = q; q = d - c * q; } invf[n] = (int) (p < 0 ? p + mod : p); for (int i = n - 1; i >= 0; i--) { invf[i] = (int) ((long) invf[i + 1] * (i + 1) % mod); } return new int[][] { f, invf }; } public static void main(String[] args) throws Exception { long S = System.currentTimeMillis(); is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); solve(); out.flush(); long G = System.currentTimeMillis(); tr(G-S+"ms"); } private static boolean eof() { if(lenbuf == -1)return true; int lptr = ptrbuf; while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false; try { is.mark(1000); while(true){ int b = is.read(); if(b == -1){ is.reset(); return true; }else if(!isSpaceChar(b)){ is.reset(); return false; } } } catch (IOException e) { return true; } } private static byte[] inbuf = new byte[1024]; static int lenbuf = 0, ptrbuf = 0; private static int readByte() { if(lenbuf == -1)throw new InputMismatchException(); if(ptrbuf >= lenbuf){ ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf <= 0)return -1; } return inbuf[ptrbuf++]; } private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } // private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); } private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; } private static double nd() { return Double.parseDouble(ns()); } private static char nc() { return (char)skip(); } private static String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while(!(isSpaceChar(b))){ sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private static char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while(p < n && !(isSpaceChar(b))){ buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private static char[][] nm(int n, int m) { char[][] map = new char[n][]; for(int i = 0;i < n;i++)map[i] = ns(m); return map; } private static int[] na(int n) { int[] a = new int[n]; for(int i = 0;i < n;i++)a[i] = ni(); return a; } private static int ni() { int num = 0, b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static long nl() { long num = 0; int b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); } }
Main.java:8: error: class D3 is public, should be declared in a file named D3.java public class D3 { ^ 1 error
s129480197
p04004
C++
#include <bits/stdc++.h> using namespace std; double PI=3.141592653589793; complex <double> dftn[2100007]; complex <double> dfts[2100007]; complex <double> a1[2100007]; complex <double> b1[2100007]; complex <double> a2[2100007]; complex <double> b2[2100007]; double cosi[2100007]; complex <double> omega[2100007]; inline int potenga(int v) { for (int i=1; 1; i<<=1) { if (i>=v) { return i; } } } inline void dft(int n, int kier) { int n2=n-1; int s=0; int p; int g; for (int i=2; i<=n; i<<=1) { for (int j=0; j<n; j++) { dfts[j]=dftn[j]; dftn[j]=0; } p=n/i; if (kier) { g=0; for (int j=0; j<n; j++) { dftn[j]=dfts[(2*(j-s)+s)&n2]+omega[g]*dfts[(2*(j-s)+p+s)&n2]; s++; if (s==p) { g=j+1; s=0; } } } else { g=n; for (int j=0; j<n; j++) { dftn[j]=dfts[(2*(j-s)+s)&n2]+omega[g]*dfts[(2*(j-s)+p+s)&n2]; s++; if (s==p) { g=n-j-1; s=0; } } } } } void licz_omegi(int n1) { double kat=2.0*PI/n1; int n2=n1-1; int dod=3*n1/4; for (int i=0; i<=n1; i++) cosi[i]=cos(kat*i); for (int i=0; i<=n1; i++) omega[i]=complex <double> (cosi[i], cosi[(i+dod)&n2]); } vector <long long> fft_dokladne(vector <long long> &jed, vector <long long> &dwa) { int n1=potenga(jed.size()+dwa.size()); licz_omegi(n1); long long M=32000; for (int i=0; i<jed.size(); i++) dftn[i]=jed[i]/M; for (int i=jed.size(); i<n1; i++) dftn[i]=0; dft(n1, 1); for (int i=0; i<n1; i++) a1[i]=dftn[i]; for (int i=0; i<jed.size(); i++) dftn[i]=jed[i]%M; for (int i=jed.size(); i<n1; i++) dftn[i]=0; dft(n1, 1); for (int i=0; i<n1; i++) b1[i]=dftn[i]; for (int i=0; i<dwa.size(); i++) dftn[i]=dwa[i]/M; for (int i=dwa.size(); i<n1; i++) dftn[i]=0; dft(n1, 1); for (int i=0; i<n1; i++) a2[i]=dftn[i]; for (int i=0; i<dwa.size(); i++) dftn[i]=dwa[i]%M; for (int i=dwa.size(); i<n1; i++) dftn[i]=0; dft(n1, 1); for (int i=0; i<n1; i++) b2[i]=dftn[i]; vector <long long> ret; for (int i=0; i<n1; i++) ret.push_back(0); for (int i=0; i<n1; i++) dftn[i]=a1[i]*a2[i]; dft(n1, 0); for (int i=0; i<n1; i++) ret[i]+=(llround(dftn[i].real()/n1)%mod)*((M*M)%1000000007); for (int i=0; i<n1; i++) dftn[i]=a1[i]*b2[i]+b1[i]*a2[i]; dft(n1, 0); for (int i=0; i<n1; i++) ret[i]+=(llround(dftn[i].real()/n1)%mod)*M; for (int i=0; i<n1; i++) dftn[i]=b1[i]*b2[i]; dft(n1, 0); for (int i=0; i<n1; i++) ret[i]+=llround(dftn[i].real()/n1)%mod; for (int i=0; i<ret.size(); i++) ret[i]%=1000000007; return ret; } int n, m, k; int s; long long mod=1000000007; long long sil[1000007]; long long odw[1000007]; long long do3[1000007]; vector <long long> d1, d2, d3; long long wyn; long long dziel(long long a, long long b) { long long wyk=mod-2; while(wyk) { if (wyk&1) { a*=b; a%=mod; } b*=b; b%=mod; wyk>>=1; } return a; } long long komb(int a, int b) { if (b<0 || b>a) return 0; return (sil[a]*((odw[b]*odw[a-b])%mod))%mod; } long long komz(int a, int b) { return komb(a+b-1, b); } int main() { scanf("%d%d%d", &n, &m, &k); s=n+m+k; sil[0]=1; odw[0]=1; do3[0]=1; for (int i=1; i<=s; i++) sil[i]=(sil[i-1]*i)%mod; odw[s]=dziel(1, sil[s]); for (int i=s-1; i; i--) odw[i]=(odw[i+1]*(i+1))%mod; for (int i=1; i<=s; i++) do3[i]=(do3[i-1]*3)%mod; for (int i=0; i<=m; i++) d1.push_back((komz(n, i)*odw[n+i-1])%mod); for (int i=0; i<=k; i++) d2.push_back(odw[i]); d3=fft_dokladne(d1, d2); for (int i=0; i<=m+k; i++) wyn+=(d3[i]*((sil[n+i-1]*do3[m+k-i])%mod))%mod; printf("%lld\n", wyn%mod); return 0; }
a.cc: In function 'std::vector<long long int> fft_dokladne(std::vector<long long int>&, std::vector<long long int>&)': a.cc:137:41: error: 'mod' was not declared in this scope; did you mean 'modf'? 137 | ret[i]+=(llround(dftn[i].real()/n1)%mod)*((M*M)%1000000007); | ^~~ | modf a.cc:143:41: error: 'mod' was not declared in this scope; did you mean 'modf'? 143 | ret[i]+=(llround(dftn[i].real()/n1)%mod)*M; | ^~~ | modf a.cc:149:40: error: 'mod' was not declared in this scope; did you mean 'modf'? 149 | ret[i]+=llround(dftn[i].real()/n1)%mod; | ^~~ | modf