submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s289272593
p03722
C++
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define N 11000 #define INF 111111111111111111ll typedef long long ll; ll n, m; ll d[N], u[N], v[N]; bool inf(){ for (int i = 1; i <= n; ++i) d[i] = INF; d[n] = 0; for (int k = 0; k < n; ++k) { for (int i = 0; i < m; ++i) { int x = u[i], y = v[i]; if (d[y] > d[x] + w[i]) { //printf("%lld %lld %lld\n", e.from, e.to, e.cost); d[y] = d[x] + w[i]; if (k == n - 1) return true; } } } return false; } int main() { while (scanf("%lld%lld", &n, &m) != EOF) { for (int i = 0; i < m; ++i) { scanf("%lld%lld%lld", &u[i], &v[i], &w[i]); w[i] = -w[i]; } if (inf()) puts("inf"); else printf("%lld\n", -d[1]); } return 0; } //#include <stdio.h> //#include <string.h> //#include <algorithm> //#include <vector> // // //#define N 220 //#define N 102000 // //struct Edge { // int from, to, dis; //}; // //int pa[N]; //Edge edges[N]; //vector<int> G[N]; // //int findset(int x) { // return pa[x] == x ? pa[x] = findset(pa[x]); //} // //int main() { // // return 0; //}
a.cc: In function 'bool inf()': a.cc:21:31: error: 'w' was not declared in this scope 21 | if (d[y] > d[x] + w[i]) { | ^ a.cc: In function 'int main()': a.cc:34:50: error: 'w' was not declared in this scope 34 | scanf("%lld%lld%lld", &u[i], &v[i], &w[i]); | ^
s170609867
p03722
C++
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define N 11000 #define INF 111111111111111111ll typedef long long ll; ll n, m; ll d[N], u[N], v[N]; bool inf(){ for (int i = 1; i <= n; ++i) d[i] = INF; d[1] = 0; for (int k = 0; k < n; ++k) { for (int i = 0; i < m; ++i) { int x = u[i], y = v[i]; if (d[y] > d[x] + w[i]) { //printf("%lld %lld %lld\n", e.from, e.to, e.cost); d[y] = d[x] + w[i]; if (k == n - 1) return true; } } } return false; } int main() { while (scanf("%lld%lld", &n, &m) != EOF) { for (int i = 0; i < m; ++i) { scanf("%lld%lld%lld", &u[i], &v[i], &w[i]); w[i] = -w[i]; } if (inf()) puts("inf"); else printf("%lld\n", -d[n]); } return 0; } //#include <stdio.h> //#include <string.h> //#include <algorithm> //#include <vector> // // //#define N 220 //#define N 102000 // //struct Edge { // int from, to, dis; //}; // //int pa[N]; //Edge edges[N]; //vector<int> G[N]; // //int findset(int x) { // return pa[x] == x ? pa[x] = findset(pa[x]); //} // //int main() { // // return 0; //}
a.cc: In function 'bool inf()': a.cc:21:31: error: 'w' was not declared in this scope 21 | if (d[y] > d[x] + w[i]) { | ^ a.cc: In function 'int main()': a.cc:34:50: error: 'w' was not declared in this scope 34 | scanf("%lld%lld%lld", &u[i], &v[i], &w[i]); | ^
s720535760
p03722
C++
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define N 11000 #define INF 111111111111111111ll typedef long long ll; int n, m; ll d[N], u[N], v[N]; bool inf(){ for (int i = 1; i <= n; ++i) d[i] = INF; d[1] = 0; for (int k = 0; k < n; ++k) { for (int i = 0; i < m; ++i) { int x = u[i], y = v[i]; if (d[y] > d[x] + w[i]) { //printf("%lld %lld %lld\n", e.from, e.to, e.cost); d[y] = d[x] + w[i]; if (k == n - 1) return true; } } } return false; } int main() { while (scanf("%d%d", &n, &m) != EOF) { for (int i = 0; i < m; ++i) { scanf("%lld%lld%lld", &u[i], &v[i], &w[i]); w[i] = -w[i]; } if (inf()) puts("inf"); else printf("%lld\n", -d[n]); } return 0; } //#include <stdio.h> //#include <string.h> //#include <algorithm> //#include <vector> // // //#define N 220 //#define N 102000 // //struct Edge { // int from, to, dis; //}; // //int pa[N]; //Edge edges[N]; //vector<int> G[N]; // //int findset(int x) { // return pa[x] == x ? pa[x] = findset(pa[x]); //} // //int main() { // // return 0; //}
a.cc: In function 'bool inf()': a.cc:21:31: error: 'w' was not declared in this scope 21 | if (d[y] > d[x] + w[i]) { | ^ a.cc: In function 'int main()': a.cc:34:50: error: 'w' was not declared in this scope 34 | scanf("%lld%lld%lld", &u[i], &v[i], &w[i]); | ^
s413295001
p03722
C++
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define N 11000 #define INF 111111111111111111ll typedef long long ll; int n, m; ll d[N], u[N], v[N]; bool inf(){ for (int i = 1; i <= n; ++i) d[i] = INF; d[1] = 0; for (int k = 0; k < n; ++k) { for (int i = 0; i < m; ++i) { int x = u[i], y = v[i]; if (d[y] >= d[x] + w[i]) { //printf("%lld %lld %lld\n", e.from, e.to, e.cost); d[y] = d[x] + w[i]; if (k == n - 1) return true; } } } return false; } int main() { while (scanf("%d%d", &n, &m) != EOF) { for (int i = 0; i < m; ++i) { scanf("%lld%lld%lld", &u[i], &v[i], &w[i]); w[i] = -w[i]; } if (inf()) puts("inf"); else printf("%lld\n", -d[n]); } return 0; } //#include <stdio.h> //#include <string.h> //#include <algorithm> //#include <vector> // // //#define N 220 //#define N 102000 // //struct Edge { // int from, to, dis; //}; // //int pa[N]; //Edge edges[N]; //vector<int> G[N]; // //int findset(int x) { // return pa[x] == x ? pa[x] = findset(pa[x]); //} // //int main() { // // return 0; //}
a.cc: In function 'bool inf()': a.cc:21:32: error: 'w' was not declared in this scope 21 | if (d[y] >= d[x] + w[i]) { | ^ a.cc: In function 'int main()': a.cc:34:50: error: 'w' was not declared in this scope 34 | scanf("%lld%lld%lld", &u[i], &v[i], &w[i]); | ^
s101444100
p03722
C++
#include <iostream> #define INF 10000000000000 using namespace std; struct edge { int from; int to; long long int cost; }; edge es[2005]; long long int d[1005]; int V, E; bool negative[1005]; void shortest_path(int s) { for (int i = 0; i <= V; i++) d[i] = INF; d[s] = 0; for (int j = 0; j <= V; j++) { bool update = false; for (int i = 0; i < E; i++) { edge e = es[i]; if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; update = true; } } if (!update) break; } } bool find_negative_loop() { memset(negative, false, 1005); for (int j = 0; j <= V; j++) { for (int i = 0; i < E; i++) { edge e = es[i]; if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; if (i == V - 1) return true; } } } return false; } int main() { cin >> V >> E; for (int i = 0; i < E; i++) { cin >> es[i].from >> es[i].to >> es[i].cost; es[i].cost *= -1; } shortest_path(1); if (!find_negative_loop()) cout << -d[V] << endl; else cout << "inf" << endl; return 0; }
a.cc: In function 'bool find_negative_loop()': a.cc:44:9: error: 'memset' was not declared in this scope 44 | memset(negative, false, 1005); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | #define INF 10000000000000
s797797911
p03722
C++
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> #include<utility> using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; typedef long double ld; const int inf = 1e+7; const ll INF = 1e+14; typedef pair<int, int> P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second struct edge { ll from, to, cost; }; edge es[2020]; ll d[1010]; ll N, M; void bellman_ford(int s) { rep(i, N) d[i] = inf; d[s] = 0; while(true) { bool update = false; rep(i, M) { edge e = es[i]; if (d[e.from] != inf && d[e.to] > d[e.from] + e.cost ) { d[e.to] = d[e.from] + e.cost; update = true; } } if (!update) break; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> M; rep(i, M) { ll a, b, c; cin >> a >> b >> c; a--; b--;c *= -1; es[i] = {a, b, c}; } bellman_ford(0); int ans = d[N - 1]; bool negative_loop[1010]; rep(i , N) negative_loop[i] = false; rep(i, N) { rep(j, M) { edge e = es[j]; if (d[e.to] > d[e.from] + e.cost ) { d[e.to] = d[e.from] + e.cost; if (i == N - 1) { negative_loop[e.to] = true; negative_loop[e.from] = true; } } } if (negative_loop[N - 1] == true) cout << "inf" << endl; else cout << ans * (-1) << endl; return 0; }
a.cc: In function 'int main()': a.cc:103:2: error: expected '}' at end of input 103 | } | ^ a.cc:65:12: note: to match this '{' 65 | int main() { | ^
s512741592
p03722
C++
#include <iostream> #include <cmath> #include <vector> #include <list> #include <set> #include <unordered_map> #define BIG 998244353 using namespace std; typedef struct Node{ vector<long> weight; vector<int> connected; } node; long maxscore = LONG_MIN; void search(const vector<node>& graph,unordered_map<int,long> history,int last,long score){ if(maxscore == LONG_MAX)return; node n = graph[last]; for(int i = 0;i < n.connected.size();++i){ if(history.find(n.connected[i]) != history.end()){ if(history[n.connected[i]] <= score + n.weight[i])maxscore = LONG_MAX; return; } else{ long nscore = score + n.weight[i]; if(n.connected[i] == graph.size() - 1 && nscore > maxscore)maxscore = nscore; unordered_map<int,long> nhis(history); nhis[n.connected[i]] = nscore; search(graph,nhis,n.connected[i],nscore); } } } int main() { int n,m; cin >> n >> m; vector<node> graph(n,{vector<long>(),vector<int>()}); for(int i = 0;i < m;++i){ int a,b,c; cin >> a >> b >> c; --a; --b; graph[a].connected.push_back(b); graph[a].weight.push_back(c); } search(graph,unordered_map<int,long>(),0,0); cout << maxscore << endl; }
a.cc:17:17: error: 'LONG_MIN' was not declared in this scope 17 | long maxscore = LONG_MIN; | ^~~~~~~~ a.cc:7:1: note: 'LONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 6 | #include <unordered_map> +++ |+#include <climits> 7 | a.cc: In function 'void search(const std::vector<Node>&, std::unordered_map<int, long int>, int, long int)': a.cc:21:20: error: 'LONG_MAX' was not declared in this scope 21 | if(maxscore == LONG_MAX)return; | ^~~~~~~~ a.cc:21:20: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' a.cc:25:74: error: 'LONG_MAX' was not declared in this scope 25 | if(history[n.connected[i]] <= score + n.weight[i])maxscore = LONG_MAX; | ^~~~~~~~ a.cc:25:74: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s248914974
p03722
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Objects; import java.util.StringTokenizer; public class Main public static void main(String[] args) { SC sc = new SC(System.in); int N=sc.nextInt(); int M=sc.nextInt(); long INF=100_000_000_000_000_000L; long[] COST=new long[N+1]; Vertex[] cycle=new Vertex[N+1]; boolean[] negative=new boolean[N+1]; for(int i=0; i<M; i++) { int from=sc.nextInt(); int to=sc.nextInt(); long cost=sc.nextLong(); cycle[from].add(to, -cost); } Arrays.fill(COST, INF); COST[0]=0; COST[1]=0; for(int i=0; i<N; i++) { boolean update=false; for(int j=1; j<=N; j++) { for(int k=0; k<cycle[j].size(); k++) { if(COST[j]!=INF && COST[cycle[j].getKey(k)]>COST[j]+cycle[j].getValue(k)) { COST[cycle[j].getKey(k)]=COST[j]+cycle[j].getValue(k); update=true; } } if(update) { if(i==N-1) { pl("inf"); System.exit(0); } } } } pl(-COST[N]); } static class SC { private BufferedReader reader = null; private StringTokenizer tokenizer = null; public SC(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); } public String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new UncheckedIOException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { throw new UncheckedIOException(e); } } } public static void pl(Object o) { System.out.println(o); } public static void pl() { System.out.println(); } public static void p(Object o) { System.out.print(o); } public static final class Pair<K, V>{ //powered by mikit //Pair<任意の型、任意の型>だが、下の機能すべて使うには、Pair<Integer,Long>でないと不可能 public K key; public V value; public Pair(K key, V value) { this.key = key; this.value = value; } public static long getValue(Pair<Integer,Long> a) { return a.value; } public static int getKey(Pair<Integer,Long> a) { return a.key; } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> pair = (Pair<?, ?>) o; return Objects.equals(key, pair.key) && Objects.equals(value, pair.value); } public int hashCode() { return Objects.hash(key, value); } } public static class Vertex{ ArrayList <Pair<Integer,Long>> rinsetu=new ArrayList<Pair<Integer,Long>>(); public void add(int V,long cost) { rinsetu.add(new Pair<Integer, Long>(V,cost)); } public void show() { //隣接リストを出力 for(int i=0; i<rinsetu.size(); i++) { System.out.println(rinsetu.get(i)); } } public void sort_by_cost() { //コストの低い順にソートします rinsetu.sort(Comparator.comparing(p -> p.value)); } public void sort_by_Vertex() { //向かう頂点の番号順にソートします rinsetu.sort(Comparator.comparing(p -> p.key)); } public long getValue(int i) { return Pair.getValue(rinsetu.get(i)); //Valueを取り出す } public Pair<Integer,Long> get(int i) { return rinsetu.get(i); //Pairをぶっこ抜く } public int getKey(int i) { return Pair.getKey(rinsetu.get(i)); //Valueを取り出す } public void changeKey(int i,int value) { //リストのペアの前の値(Key,Value)のKeyを書き換え Pair<Integer,Long> tmp=new Pair<Integer, Long>(value,Pair.getValue(rinsetu.get(i))); rinsetu.set(i, tmp); } public void changeValue(int i,long value) { //リストのペアの後ろの値(Key,Value)のValueを書き換え Pair<Integer,Long> tmp=new Pair<Integer, Long>(Pair.getKey(rinsetu.get(i)),value); rinsetu.set(i, tmp); } public void changeKeyValue(int i,int key,long value) { //リストのペアを書き換え(Key,Valueどちらも) Pair<Integer,Long> tmp=new Pair<Integer, Long>(key,value); rinsetu.set(i, tmp); } public int size() { //次数を返す return rinsetu.size(); } public int find_Vertex(int a) { //ある頂点から本当に特定の辺に行くか? 逐次探索なので速さはお察し for(int i=0; i<rinsetu.size(); i++) { if(a==Pair.getKey(rinsetu.get(i))) { return i; } } return -1; } } }
Main.java:12: error: '{' expected public class Main ^ Main.java:13: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args) { ^ (use --enable-preview to enable unnamed classes) Main.java:166: error: class, interface, enum, or record expected } ^ 3 errors
s935602029
p03722
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Objects; import java.util.StringTokenizer; public class D61 { public static void main(String[] args) { SC sc = new SC(System.in); int N=sc.nextInt(); int M=sc.nextInt(); long INF=1_000_000_000_000_000L; long[] COST=new long[N+1]; Vertex[] graph=new Vertex[N+1]; Vertex[] cycle=new Vertex[N+1]; for(int i=0; i<=N; i++) { graph[i]=new Vertex(); cycle[i]=new Vertex(); COST[i]=INF; } for(int i=0; i<M; i++) { int from=sc.nextInt(); int to=sc.nextInt(); long cost=sc.nextLong(); graph[from].add(to, cost); cycle[from].add(to, -cost); } COST[0]=0; COST[1]=0; for(int i=1; i<=N; i++) { boolean update=false; for(int j=1; j<=M; j++) { for(int k=0; k<cycle[j].size(); k++) { if(COST[j]!=INF && COST[cycle[j].getKey(k)]>COST[j]+cycle[j].getValue(k)) { COST[cycle[j].getKey(k)]=COST[j]+cycle[j].getValue(k); update=true; } } } if(update==true) { if(i==N) { pl("inf"); System.exit(0); } } } Arrays.fill(COST, -INF); COST[0]=0; COST[1]=0; for(int i=1; i<=N; i++) { boolean update=false; for(int j=1; j<=M; j++) { for(int k=0; k<graph[j].size(); k++) { if(COST[j]!=-INF && COST[graph[j].getKey(k)]<COST[j]+graph[j].getValue(k)) { COST[graph[j].getKey(k)]=COST[j]+graph[j].getValue(k); update=true; } } } if(update==true) { if(i==N) { pl("inf"); System.exit(0); } } } pl(COST[N]); } static class SC { private BufferedReader reader = null; private StringTokenizer tokenizer = null; public SC(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); } public String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new UncheckedIOException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { throw new UncheckedIOException(e); } } } public static void pl(Object o) { System.out.println(o); } public static void pl() { System.out.println(); } public static void p(Object o) { System.out.print(o); } public static final class Pair<K, V>{ //powered by mikit //Pair<任意の型、任意の型>だが、下の機能すべて使うには、Pair<Integer,Long>でないと不可能 public K key; public V value; public Pair(K key, V value) { this.key = key; this.value = value; } public static long getValue(Pair<Integer,Long> a) { return a.value; } public static int getKey(Pair<Integer,Long> a) { return a.key; } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> pair = (Pair<?, ?>) o; return Objects.equals(key, pair.key) && Objects.equals(value, pair.value); } public int hashCode() { return Objects.hash(key, value); } } public static class Vertex{ ArrayList <Pair<Integer,Long>> rinsetu=new ArrayList<Pair<Integer,Long>>(); public void add(int V,long cost) { rinsetu.add(new Pair<Integer, Long>(V,cost)); } public void show() { //隣接リストを出力 for(int i=0; i<rinsetu.size(); i++) { System.out.println(rinsetu.get(i)); } } public void sort_by_cost() { //コストの低い順にソートします rinsetu.sort(Comparator.comparing(p -> p.value)); } public void sort_by_Vertex() { //向かう頂点の番号順にソートします rinsetu.sort(Comparator.comparing(p -> p.key)); } public long getValue(int i) { return Pair.getValue(rinsetu.get(i)); //Valueを取り出す } public Pair<Integer,Long> get(int i) { return rinsetu.get(i); //Pairをぶっこ抜く } public int getKey(int i) { return Pair.getKey(rinsetu.get(i)); //Valueを取り出す } public void changeKey(int i,int value) { //リストのペアの前の値(Key,Value)のKeyを書き換え Pair<Integer,Long> tmp=new Pair<Integer, Long>(value,Pair.getValue(rinsetu.get(i))); rinsetu.set(i, tmp); } public void changeValue(int i,long value) { //リストのペアの後ろの値(Key,Value)のValueを書き換え Pair<Integer,Long> tmp=new Pair<Integer, Long>(Pair.getKey(rinsetu.get(i)),value); rinsetu.set(i, tmp); } public void changeKeyValue(int i,int key,long value) { //リストのペアを書き換え(Key,Valueどちらも) Pair<Integer,Long> tmp=new Pair<Integer, Long>(key,value); rinsetu.set(i, tmp); } public int size() { //次数を返す return rinsetu.size(); } public int find_Vertex(int a) { //ある頂点から本当に特定の辺に行くか? 逐次探索なので速さはお察し for(int i=0; i<rinsetu.size(); i++) { if(a==Pair.getKey(rinsetu.get(i))) { return i; } } return -1; } } }
Main.java:12: error: class D61 is public, should be declared in a file named D61.java public class D61 { ^ 1 error
s802011317
p03722
C++
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define F first #define S second #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define SORT(c) sort((c).begin(),(c).end()) typedef long long ll; const ll INF = 1LL<<60; const ll mod = 1e9 + 7; const int MAX_N = 5e5 + 5; int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; vector<ll> prime; ll inv[MAX_N], fac[MAX_N]; template <class T = ll> T in() { T x; cin >> x; return (x); } inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; } inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); } inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; } inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } } inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; } inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } } vector<vector<pair<int,int>>> Edge; vector<int> node; bool bellman_ford(int n,int s) { node = vector<int>(node.size(),INF); node[s] = 0; REP (i,n) { REP (j,Edge.size()) { REP (k,Edge[j].size()) { int from = j,to = Edge[j][k].F; int cost = Edge[j][k].S; if (node[from] != INF && node[to] > node[from] + cost) { node[to] = node[from] + cost; if (i == n - 1) return true; } } } } return false; } signed main() { int n,m; cin >> n >> m; cost = vector<int>(m); Edge = vector<vector<pair<int,int>>>(m); REP (i,m) { int x,y,z; cin >> x >> y >> z; Edge[x-1].push_back({y-1,-z}); } if (bellman_ford(0,n)) { cout << "inf" << endl; } else { cout << -node[n-1] << endl; } }
a.cc: In function 'int main()': a.cc:56:9: error: 'cost' was not declared in this scope; did you mean 'cosl'? 56 | cost = vector<int>(m); | ^~~~ | cosl
s690271594
p03722
C++
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define F first #define S second #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define SORT(c) sort((c).begin(),(c).end()) typedef long long ll; const ll INF = 1LL<<60; const ll mod = 1e9 + 7; const int MAX_N = 5e5 + 5; int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; vector<ll> prime; ll inv[MAX_N], fac[MAX_N]; template <class T = ll> T in() { T x; cin >> x; return (x); } inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; } inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); } inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; } inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } } inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; } inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } } vector<vector<pair<int,int>>> Edge; vector<int> node; bool bellman_ford(int n,int s) { node = vector<int>(node.size(),INF); node[s] = 0; REP (i,n) { REP (j,Edge.size()) { REP (k,Edge[j].size()) { int from = j,to = Edge[j][k].F; int cost = Edge[j][k].S; if (node[from] != INF && node[to] > node[from] + cost) { node[to] = node[from] + cost; if (i == n - 1) return true; } } } } return false; } signed main() { int n,m; cin >> n >> m; cost = vector<int>(m); Edge = vector<vector<pair<int,int>>>(m); REP (i,m) { int x,y,z; cin >> x >> y >> z; Edge[x-1].push_back{y-1,-z}; } if (bellman_ford(0,n)) { cout << "inf" << endl; } else { cout << -node[n-1] << endl; } }
a.cc: In function 'int main()': a.cc:56:9: error: 'cost' was not declared in this scope; did you mean 'cosl'? 56 | cost = vector<int>(m); | ^~~~ | cosl a.cc:61:36: error: expected ';' before '{' token 61 | Edge[x-1].push_back{y-1,-z}; | ^ | ; a.cc:61:27: error: statement cannot resolve address of overloaded function 61 | Edge[x-1].push_back{y-1,-z};
s946065351
p03722
C++
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define F first #define S second #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define SORT(c) sort((c).begin(),(c).end()) typedef long long ll; const ll INF = 1LL<<60; const ll mod = 1e9 + 7; const int MAX_N = 5e5 + 5; int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; vector<ll> prime; ll inv[MAX_N], fac[MAX_N]; template <class T = ll> T in() { T x; cin >> x; return (x); } inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; } inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); } inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; } inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } } inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; } inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } } vector<int> cost; vector<pair<int,int>> Edge; vector<int> node; bool bellman_ford(int n,int s) { node = vector<int>(node.size(),INF); node[s] = 0; REP (i,n) { REP (j,Edge.size()) { int from = Edge[j],to = Edge[j]; if (node[from] != INF && node[to] > node[from] + cost[j]) { node[to] = node[from] + cost[j]; if (i == n - 1) return true; } } } return false; } signed main() { int n,m; cin >> n >> m; node = vector<int>(n); cost = vector<int>(m); Edge = vector<pair<int,int>>(m); REP (i,m) { cin >> Edge[i].F >> Edge[i].S >> cost[i]; Edge[i].F--;Edge[i].S--; Edge[i].F *= (-1);Edge[i].S *= (-1); } if (bellman_ford(0,n)) { cout << "inf" << endl; } else { cout << -cost[n-1] << endl; } }
a.cc: In function 'bool bellman_ford(long long int, long long int)': a.cc:41:42: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'long long int' in initialization 41 | int from = Edge[j],to = Edge[j]; | ^ a.cc:41:55: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'long long int' in initialization 41 | int from = Edge[j],to = Edge[j]; | ^
s178398541
p03722
C++
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define F first #define S second #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define SORT(c) sort((c).begin(),(c).end()) typedef long long ll; const ll INF = 1LL<<60; const ll mod = 1e9 + 7; const int MAX_N = 5e5 + 5; int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; vector<ll> prime; ll inv[MAX_N], fac[MAX_N]; template <class T = ll> T in() { T x; cin >> x; return (x); } inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; } inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); } inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; } inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } } inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; } inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } } typedef pair<int, pair<int, int>> Edge; class UnionFind { private: vector<int> par; public: UnionFind(int N) { par = vector<int>(N, -1LL); } int find(int x); ll size(int x); void unite(int x, int y); bool same(int x, int y); }; class Kruskal { private: UnionFind *uf; vector<Edge> e; public: vector<Edge> mst; Kruskal(int N) { uf = new UnionFind(N); } void add(int x, int y, ll z); void run(); }; //----UnionFind------------------------------- int UnionFind::find(int x) { if (par[x] < 0) return x; else return par[x] = find(par[x]); } ll UnionFind::size(int x) { return -par[find(x)]; } void UnionFind::unite(int x, int y) { x = find(x); y = find(y); //大きい方に小さい方をくっ付ける if (size(x) < size(y)) swap(x, y); par[x] += par[y]; par[y] = x; } bool UnionFind::same(int x, int y) { x = find(x); y = find(y); return x == y; } //----Kruskal------------------------------- void Kruskal::add(int x, int y, ll z) { //x < y if (x > y) swap(x, y); e.push_back({ z,{x,y} }); } void Kruskal::run() { sort(e.begin(), e.end()); e.erase(unique(e.begin(), e.end()), e.end()); for (auto x : e) { if (uf->same(x.second.first, x.second.second)) { continue; } else { mst.push_back(x); uf->unite(x.second.first, x.second.second); } } } vector<int> cost; vector<pair<int,int>> Edge; vector<int> node; bool bellman_ford(int n,int s) { node = vector<int>(node.size(),INF); node[s] = 0; REP (i,n) { REP (j,Edge.size()) { int from = Edge[j],to = Edge[j]; if (node[from] != INF && node[to] > node[from] + cost[j]) { node[to] = node[from] + cost[j]; if (i == n - 1) return true; } } } return false; } signed main() { int n,m; cin >> n >> m; node = vector<int>(n); cost = vector<int>(m); Edge = vector<pair<int,int>>(m); REP (i,m) { cin >> Edge[i].F >> Edge[i].S >> cost[i]; Edge[i].F--;Edge[i].S--; Edge[i].F *= (-1);Edge[i].S *= (-1); } if (bellman_ford(0,n)) { cout << "inf" << endl; } else { cout << -cost[n-1] << endl; } }
a.cc:110:23: error: 'std::vector<std::pair<long long int, long long int> > Edge' redeclared as different kind of entity 110 | vector<pair<int,int>> Edge; | ^~~~ a.cc:32:35: note: previous declaration 'typedef struct std::pair<long long int, std::pair<long long int, long long int> > Edge' 32 | typedef pair<int, pair<int, int>> Edge; | ^~~~ a.cc: In function 'bool bellman_ford(long long int, long long int)': a.cc:117:28: error: expected primary-expression before '.' token 117 | REP (j,Edge.size()) { | ^ a.cc:9:41: note: in definition of macro 'FOR' 9 | #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP (j,Edge.size()) { | ^~~ a.cc:118:40: error: expected primary-expression before '[' token 118 | int from = Edge[j],to = Edge[j]; | ^ a.cc:119:55: error: 'to' was not declared in this scope; did you mean 'tm'? 119 | if (node[from] != INF && node[to] > node[from] + cost[j]) { | ^~ | tm a.cc: In function 'int main()': a.cc:133:14: error: expected unqualified-id before '=' token 133 | Edge = vector<pair<int,int>>(m); | ^ a.cc:135:28: error: expected primary-expression before '[' token 135 | cin >> Edge[i].F >> Edge[i].S >> cost[i]; | ^ a.cc:135:41: error: expected primary-expression before '[' token 135 | cin >> Edge[i].F >> Edge[i].S >> cost[i]; | ^ a.cc:136:21: error: structured binding declaration cannot have type 'Edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'} 136 | Edge[i].F--;Edge[i].S--; | ^~~ a.cc:136:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:136:22: error: redeclaration of 'auto i' 136 | Edge[i].F--;Edge[i].S--; | ^ a.cc:134:14: note: 'long long int i' previously declared here 134 | REP (i,m) { | ^ a.cc:9:29: note: in definition of macro 'FOR' 9 | #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) | ^ a.cc:134:9: note: in expansion of macro 'REP' 134 | REP (i,m) { | ^~~ a.cc:136:24: error: expected initializer before '.' token 136 | Edge[i].F--;Edge[i].S--; | ^ a.cc:136:24: error: expected ';' before '.' token a.cc:136:33: error: structured binding declaration cannot have type 'Edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'} 136 | Edge[i].F--;Edge[i].S--; | ^~~ a.cc:136:33: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:136:36: error: expected initializer before '.' token 136 | Edge[i].F--;Edge[i].S--; | ^ a.cc:137:21: error: structured binding declaration cannot have type 'Edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'} 137 | Edge[i].F *= (-1);Edge[i].S *= (-1); | ^~~ a.cc:137:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:137:24: error: expected initializer before '.' token 137 | Edge[i].F *= (-1);Edge[i].S *= (-1); | ^ a.cc:137:39: error: structured binding declaration cannot have type 'Edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'} 137 | Edge[i].F *= (-1);Edge[i].S *= (-1); | ^~~ a.cc:137:39: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:137:42: error: expected initializer before '.' token 137 | Edge[i].F *= (-1);Edge[i].S *= (-1); | ^
s654491744
p03722
C++
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define F first #define S second #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define SORT(c) sort((c).begin(),(c).end()) typedef long long ll; const ll INF = 1LL<<60; const ll mod = 1e9 + 7; const int MAX_N = 5e5 + 5; int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; vector<ll> prime; ll inv[MAX_N], fac[MAX_N]; template <class T = ll> T in() { T x; cin >> x; return (x); } inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; } inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); } inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; } inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } } inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; } inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } } typedef pair<int, pair<int, int>> edge; class UnionFind { private: vector<int> par; public: UnionFind(int N) { par = vector<int>(N, -1LL); } int find(int x); ll size(int x); void unite(int x, int y); bool same(int x, int y); }; class Kruskal { private: UnionFind *uf; vector<edge> e; public: vector<edge> mst; Kruskal(int N) { uf = new UnionFind(N); } void add(int x, int y, ll z); void run(); }; //----UnionFind------------------------------- int UnionFind::find(int x) { if (par[x] < 0) return x; else return par[x] = find(par[x]); } ll UnionFind::size(int x) { return -par[find(x)]; } void UnionFind::unite(int x, int y) { x = find(x); y = find(y); //大きい方に小さい方をくっ付ける if (size(x) < size(y)) swap(x, y); par[x] += par[y]; par[y] = x; } bool UnionFind::same(int x, int y) { x = find(x); y = find(y); return x == y; } //----Kruskal------------------------------- void Kruskal::add(int x, int y, ll z) { //x < y if (x > y) swap(x, y); e.push_back({ z,{x,y} }); } void Kruskal::run() { sort(e.begin(), e.end()); e.erase(unique(e.begin(), e.end()), e.end()); for (auto x : e) { if (uf->same(x.second.first, x.second.second)) { continue; } else { mst.push_back(x); uf->unite(x.second.first, x.second.second); } } } vector<int> cost; vector<pair<int,int>> edge; vector<int> node; bool bellman_ford(int n,int s) { node = vector<int>(node.size(),INF); node[s] = 0; REP (i,n) { REP (j,edge.size()) { int from = edge[j],to = edge[j]; if (node[from] != INF && node[to] > node[from] + cost[j]) { node[to] = node[from] + cost[j]; if (i == n - 1) return true; } } } return false; } signed main() { int n,m; cin >> n >> m; node = vector<int>(n); cost = vector<int>(m); edge = vector<pair<int,int>>(m); REP (i,m) { cin >> edge[i].F >> edge[i].S >> cost[i]; edge[i].F--;edge[i].S--; edge[i].F *= (-1);edge[i].S *= (-1); } if (bellman_ford(0,n)) { cout << "inf" << endl; } else { cout << -cost[n-1] << endl; } }
a.cc:110:23: error: 'std::vector<std::pair<long long int, long long int> > edge' redeclared as different kind of entity 110 | vector<pair<int,int>> edge; | ^~~~ a.cc:32:35: note: previous declaration 'typedef struct std::pair<long long int, std::pair<long long int, long long int> > edge' 32 | typedef pair<int, pair<int, int>> edge; | ^~~~ a.cc: In function 'bool bellman_ford(long long int, long long int)': a.cc:117:28: error: expected primary-expression before '.' token 117 | REP (j,edge.size()) { | ^ a.cc:9:41: note: in definition of macro 'FOR' 9 | #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP (j,edge.size()) { | ^~~ a.cc:118:40: error: expected primary-expression before '[' token 118 | int from = edge[j],to = edge[j]; | ^ a.cc:119:55: error: 'to' was not declared in this scope; did you mean 'tm'? 119 | if (node[from] != INF && node[to] > node[from] + cost[j]) { | ^~ | tm a.cc: In function 'int main()': a.cc:133:14: error: expected unqualified-id before '=' token 133 | edge = vector<pair<int,int>>(m); | ^ a.cc:135:28: error: expected primary-expression before '[' token 135 | cin >> edge[i].F >> edge[i].S >> cost[i]; | ^ a.cc:135:41: error: expected primary-expression before '[' token 135 | cin >> edge[i].F >> edge[i].S >> cost[i]; | ^ a.cc:136:21: error: structured binding declaration cannot have type 'edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'} 136 | edge[i].F--;edge[i].S--; | ^~~ a.cc:136:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:136:22: error: redeclaration of 'auto i' 136 | edge[i].F--;edge[i].S--; | ^ a.cc:134:14: note: 'long long int i' previously declared here 134 | REP (i,m) { | ^ a.cc:9:29: note: in definition of macro 'FOR' 9 | #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) | ^ a.cc:134:9: note: in expansion of macro 'REP' 134 | REP (i,m) { | ^~~ a.cc:136:24: error: expected initializer before '.' token 136 | edge[i].F--;edge[i].S--; | ^ a.cc:136:24: error: expected ';' before '.' token a.cc:136:33: error: structured binding declaration cannot have type 'edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'} 136 | edge[i].F--;edge[i].S--; | ^~~ a.cc:136:33: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:136:36: error: expected initializer before '.' token 136 | edge[i].F--;edge[i].S--; | ^ a.cc:137:21: error: structured binding declaration cannot have type 'edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'} 137 | edge[i].F *= (-1);edge[i].S *= (-1); | ^~~ a.cc:137:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:137:24: error: expected initializer before '.' token 137 | edge[i].F *= (-1);edge[i].S *= (-1); | ^ a.cc:137:39: error: structured binding declaration cannot have type 'edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'} 137 | edge[i].F *= (-1);edge[i].S *= (-1); | ^~~ a.cc:137:39: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:137:42: error: expected initializer before '.' token 137 | edge[i].F *= (-1);edge[i].S *= (-1); | ^
s242222014
p03722
C++
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define F first #define S second #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define SORT(c) sort((c).begin(),(c).end()) typedef long long ll; const ll INF = 1LL<<60; const ll mod = 1e9 + 7; const int MAX_N = 5e5 + 5; int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; vector<ll> prime; ll inv[MAX_N], fac[MAX_N]; template <class T = ll> T in() { T x; cin >> x; return (x); } inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; } inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); } inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; } inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } } inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; } inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } } typedef pair<int, pair<int, int>> edge; class UnionFind { private: vector<int> par; public: UnionFind(int N) { par = vector<int>(N, -1LL); } int find(int x); ll size(int x); void unite(int x, int y); bool same(int x, int y); }; class Kruskal { private: UnionFind *uf; vector<edge> e; public: vector<edge> mst; Kruskal(int N) { uf = new UnionFind(N); } void add(int x, int y, ll z); void run(); }; //----UnionFind------------------------------- int UnionFind::find(int x) { if (par[x] < 0) return x; else return par[x] = find(par[x]); } ll UnionFind::size(int x) { return -par[find(x)]; } void UnionFind::unite(int x, int y) { x = find(x); y = find(y); //大きい方に小さい方をくっ付ける if (size(x) < size(y)) swap(x, y); par[x] += par[y]; par[y] = x; } bool UnionFind::same(int x, int y) { x = find(x); y = find(y); return x == y; } //----Kruskal------------------------------- void Kruskal::add(int x, int y, ll z) { //x < y if (x > y) swap(x, y); e.push_back({ z,{x,y} }); } void Kruskal::run() { sort(e.begin(), e.end()); e.erase(unique(e.begin(), e.end()), e.end()); for (auto x : e) { if (uf->same(x.second.first, x.second.second)) { continue; } else { mst.push_back(x); uf->unite(x.second.first, x.second.second); } } } vector<int> cost; vector<pair<int,int>> edge; vector<int> node; bool bellman_ford(int n,int s) { node = vector<int>(node.size(),INF); node[s] = 0; REP (i,n) { REP (j,edge.size()) { int from = edge[j],to = edge[j]; if (node[from] != INF && node[to] > node[from] + cost[j]) { node[to] = node[from] + cost[j]; if (i == n - 1) return true; } } } return false; } signed main() { int n,m; cin >> n >> m; node = vector<int>(n); cost = vector<int>(m); edge = vector<pair<int,int>>(m); FOR (i,m) { cin >> edge[i].F >> edge[i].S >> cost[i]; edge[i].F--;edge[i].S--; edge[i].F *= (-1);edge[i].S *= (-1); } if (bellman_ford(0,n)) { cout << "inf" << endl; } else { cout << -cost[n-1] << endl; } }
a.cc:134:17: error: macro "FOR" requires 3 arguments, but only 2 given 134 | FOR (i,m) { | ^ a.cc:9:9: note: macro "FOR" defined here 9 | #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) | ^~~ a.cc:110:23: error: 'std::vector<std::pair<long long int, long long int> > edge' redeclared as different kind of entity 110 | vector<pair<int,int>> edge; | ^~~~ a.cc:32:35: note: previous declaration 'typedef struct std::pair<long long int, std::pair<long long int, long long int> > edge' 32 | typedef pair<int, pair<int, int>> edge; | ^~~~ a.cc: In function 'bool bellman_ford(long long int, long long int)': a.cc:117:28: error: expected primary-expression before '.' token 117 | REP (j,edge.size()) { | ^ a.cc:9:41: note: in definition of macro 'FOR' 9 | #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP (j,edge.size()) { | ^~~ a.cc:118:40: error: expected primary-expression before '[' token 118 | int from = edge[j],to = edge[j]; | ^ a.cc:119:55: error: 'to' was not declared in this scope; did you mean 'tm'? 119 | if (node[from] != INF && node[to] > node[from] + cost[j]) { | ^~ | tm a.cc: In function 'int main()': a.cc:133:14: error: expected unqualified-id before '=' token 133 | edge = vector<pair<int,int>>(m); | ^ a.cc:134:9: error: 'FOR' was not declared in this scope 134 | FOR (i,m) { | ^~~
s377360232
p03722
C++
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <utility> #include <cstring> #include <iomanip> #include <numeric> #include <cmath> #include <queue> using namespace std; typedef long long ll; const long long INF = 1LL<<50; const int MOD = 1e9 + 7; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector<edge> G[n]; vector<ll> a(m), b(m), c(m); for(int i = 0; i < m; i++) { cin >> a[i] >> b[i] >> c[i]; a[i]--, b[i]--; c[i] = -c[i]; } vector<ll> dist(n, INF); dist[0] = 0; for(int i = 0; i < n - 1; i++) { for(int j = 0; j < m; j++) { if(dist[a[j]] == INF) continue; dist[b[j]] = min(dist[b[j]], dist[a[j]] + c[j]); } } bool negative = false; for(int j = 0; j < m; j++) { if(dist[a[j]] == INF) continue; if(dist[a[j]] + c[j] < dist[b[j]]) negative = true; } if(negative) cout << "inf" << endl; else cout << -dist[n - 1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:21:12: error: 'edge' was not declared in this scope 21 | vector<edge> G[n]; | ^~~~ a.cc:21:16: error: template argument 1 is invalid 21 | vector<edge> G[n]; | ^ a.cc:21:16: error: template argument 2 is invalid
s738097102
p03722
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define MM 1000000000 #define MOD MM+7 #define MAX 101000 #define MAP 110 #define initial_value -1 #define Pair pair<int,int> #define lPair pair<ll,ll> #define chmax(a,b) (a<b ? a=b:0) #define chmin(a,b) (a>b ? a=b:0) #define debug(a) cout << a << endl; const ll INF = 1e18; int dx[4] = {-1,0,1,0}; int dy[4] = {0,-1,0,1}; ll N,M; ll a,b,c; struct edge{ll from,to,cost;}; vector<edge> es; ll d[1000]; ll V,E; //頂点sからの最大距離 bool bellmanford(ll s){ for(int i = 0; i < V; i++) d[i] = -INF; d[s] = 0; for(int i = 0; i < V-1; i++){ //** for(int j = 0; j < E; j++){ edge e = es[j]; if(d[e.from] != -INF && d[e.to] < d[e.from]+e.cost){ d[e.to] = d[e.from] + e.cost; } } } ll dv = d[V-1]; for(int i = 0; i < V; i++){ //** for(int j = 0; j < E; j++){ edge e = es[j]; if(d[e.to] != -INF && d[e.to] < d[e.from]+e.cost){ d[e.to] = d[e.from]+e.cost; } } } if(d[V-1] > dv) return 0; else return 1; } int main(){ cin >> V >> E; for(int i = 0; i < E; i++){ ll a,b,c; cin >> a >> b >> c; a--; b--; es.push_back({a,b,c}); } if(BellmanFord(0)) cout << d[V-1] << endl; else cout << "inf" << endl; return 0; }
a.cc: In function 'int main()': a.cc:57:8: error: 'BellmanFord' was not declared in this scope; did you mean 'bellmanford'? 57 | if(BellmanFord(0)) cout << d[V-1] << endl; | ^~~~~~~~~~~ | bellmanford
s422609493
p03722
C++
#include <iostream> #include <string> #include <vector> #include <set> #include <algorithm> #include <cctype> #include <cmath> #include <queue> #include <map> #include <numeric> #include <unordered_map> #include <iomanip> #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define repi(i,a,b) for(int i=int(a);i<int(b);i++) #define all(x) (x).begin(),(x).end() template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } typedef long long ll; using namespace std; struct edge{int from,to,cost;}; int main() { ios::sync_with_stdio(false); cin.tie(0); //cout<<setprecision(10); int n,m; cin>>n>>m; vector<edge>edges(m); rep(i,m) { int a,b,c; cin>>a>>b>>c; edges[i]={a,b,c}; } bool update=0; vector<ll>dist(n+1,LLONG_MIN); dist[1]=0; rep(i,n) { update=0; rep(j,m) { update|=chmax(dist[edges[j].to],dist[edges[j].from]+edges[j].cost); } } if(update==1)cout<<"inf"<<endl; else cout<<dist[n]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:42:22: error: 'LLONG_MIN' was not declared in this scope 42 | vector<ll>dist(n+1,LLONG_MIN); | ^~~~~~~~~ a.cc:13:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 12 | #include <iomanip> +++ |+#include <climits> 13 |
s461310068
p03722
C++
//#include <bits/stdc++.h> #include <iostream> #include <complex> #include <sstream> #include <string> #include <algorithm> #include <deque> #include <list> #include <map> #include <numeric> #include <queue> #include <vector> #include <set> #include <limits> #include <cstdio> #include <cctype> #include <cmath> #include <cstring> #include <cstdlib> #include <ctime> #include <climits> #include <iomanip> #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i) #define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i) #define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++) #define SORT(v, n) sort(v, v+n) #define REVERSE(v) reverse((v).begin(), (v).end()) using namespace std; using ll = long long; const ll MOD=1000000007LL; typedef pair<int, int> P; ll ADD(ll x, ll y) { return (x+y) % MOD; } ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; } ll MUL(ll x, ll y) { return x*y % MOD; } ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; } ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); } template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;} template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;} //ベルマンフォード法 //https://abc061.contest.atcoder.jp/submissions/4484303 struct edge {ll to, cost;}; vector<vector<edge>> g; const ll INF = 1e18; const int MAX_N = 1e5; ll dist[MAX_N]; ll n,m; /* bool bellman_ford(ll s){ REP(i,n) dist[i] = INF; dist[s] = 0; bool negative_cycle = false; REP(i, n){ REP(v, n){ for(edge e: g[v]){ if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){ dist[e.to] = dist[v] + e.cost; //n回目に n-1 に更新がある -> 負のサイクル if(i == n-1 && e.to == n-1){ dist[e.to] = -INF; negative_cycle = true; } } } } } return negative_cycle; } */ bool bellman_ford(ll s){ memset(dist, 0, sizeof(dist)); bool negative_cycle = false; REP(v, n){ for(edge e: g[v]){ if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){ dist[e.to] = dist[v] + e.cost; //n回目に n-1 に更新がある -> 負のサイクル if(i == n-1 && e.to == n-1){ dist[e.to] = -INF; negative_cycle = true; } } } } return negative_cycle; } int main(void){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; g.assign(n, vector<edge>()); REP(i, m){ ll a, b, c; cin >> a >> b >> c; a--; b--; c*=-1; g[a].push_back(edge{b, c}); } bool negative_cycle = bellman_ford(0); cout << (!negative_cycle ? to_string(-dist[n-1]) : "inf" ) << endl; return 0; }
a.cc: In function 'bool bellman_ford(ll)': a.cc:89:12: error: 'i' was not declared in this scope 89 | if(i == n-1 && e.to == n-1){ | ^
s259291692
p03722
C++
/* オーダー 10**6 余裕を持って間に合う 10**7 おそらく間に合う 余裕を持って間に合う 10**8 非常にシンプルな処理でない限り厳しい おそらく間に合う 10**9 非常にシンプルな処理でない限り厳しい logn :OK n :10^7 nlogn :10^6 n**2 :10^4 n**3 :300 2**n :20 n! :10 // 各桁の和を計算する関数 int findSumOfDigits(int n) { int sum = 0; while (n > 0) { // n が 0 になるまで sum += n % 10; n /= 10; } return sum; } sort(a, a + N, greater<int>()); // a[0:N] を大きい順にソート int num[110] = {0}; // バケット for (int i = 0; i < N; ++i) { num[d[i]]++; // d[i] が 1 個増える } map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名 for (int i = 0; i < N; ++i) { auto itr = mp.find(s[i]); // s[i] が設定されているか? if(itr != mp.end() ) { mp[s[i]] += 1; } else { mp[s[i]] += 1 ; } } stack<int> s; //intをデータとするスタックを用意 s.push(1); //{} -> {1} printf("%d\n", s.top()); // 3 s.pop(); queue<int> que; //intをデータとするキューを用意 que.push(1); //{} -> {1} printf("%d\n", que.front()); // 1 que.pop(); */ #include <iostream> #include <set> #include <map> #include <string> #include <math.h> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <bitset> #include <string.h> using namespace std; // #define for(i,a,b) for (int i=(a);i<(b);++i) typedef long long ll; typedef pair<ll,ll> P; #define REP(i,n) for(long long i = 0; i < (long long)(n); i++) #define pb push_back // vectorに要素追加 #define INF (ll)1e18 const ll MAX_V = 1e3; const ll MAX_E = 2*1e3; // 頂点fromから頂点toへのコストcostの辺 struct edge {ll from, to, cost;}; edge es[MAX_V]; // 辺 EdgeS [V][3] ll d[MAX_E]; // 最短距離 ll V, E; // Vは頂点数, Eは辺数 // s番目の頂点から各頂点への最短距離を求める void shortest_path(ll s){ REP(i,V) d[i] = INF; // infで初期化 d[s] = 0; // 始点sから始点sまでの距離 while (true){ bool update = false; // 1ループ中で一度でも最短経路の更新があったか REP(i,E){ // 全ての辺について edge e = es[i]; // 解析する辺を指定 // sからe.fromまでの最短距離が探索済み かつ // 現在記録されているsからe.fromまでの最短距離 // > sからe.fromまでの最短距離 + この辺のコスト if (d[e.from]!=INF && d[e.to]>d[e.from] + e.cost){ d[e.to] = d[e.from] + e.cost; update = true; } } if (!update) break; // 更新がなくなったら終了 } } // trueなら負の経路が存在する bool find_negative_loop(){ REP(i,V) d[i] = INF; // infで初期化 d[s] = 0; // 始点sから始点sまでの距離 REP(i,V){ REP(j,E){ edge e = es[j]; if (d[e.from]!=INF && d[e.to]>d[e.from] + e.cost){ d[e.to] = d[e.from] + e.cost; // n回目にも更新があるなら負の閉路が存在する if (i==V-1) return true; } } } return false; } int main() { // 入力 cin>>V>>E; REP(i,E){ ll a,b,c;cin>>a>>b>>c;a--;b--; es[i].from = a; es[i].to = b; es[i].cost = -c; // コストをマイナスにして再消費用経路の問題に治す } // REP(i,E) printf("%lld %lld %lld\n", es[i].from, es[i].to, es[i].cost); // 解法 ll judge = find_negative_loop(); // 負の閉路が存在するか if (judge) cout << "inf" << endl; else{ shortest_path(0); ll ans = d[V-1]; // REP(i,E) printf("d[%lld] = %lld\n", i, d[i]); //出力 cout << -ans << endl; } }
a.cc: In function 'bool find_negative_loop()': a.cc:111:11: error: 's' was not declared in this scope; did you mean 'es'? 111 | d[s] = 0; // 始点sから始点sまでの距離 | ^ | es
s706741276
p03722
C++
#include <bits/stdc++.h> using namespace std; #define Inf 1000000000000000000 int main(){ int N,M; cin>>N>>M; //距離をInfで初期化 long long dis[N][N]; for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ if(i==j)dis[i][j]=0; else dis[i][j]=Inf; } } //辺の情報を受け取る(有向辺を想定) for(int i=0;i<M;i++){ int a,b,d; cin>>a>>b>>d; a--;b--; dis[a][b]=min(dis[a][b],(long long)-d); } bool flag = true; //最短距離を求める for(int k=0;k<N;k++){ for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ if(dis[i][j]>dis[i][k]+dis[k][j]){ dis[i][j]=min(Inf,dis[i][k]+dis[k][j]); } if(i==j&&dis[i][j]<0){ flag=false; } } } } if(flag)cout<<-dis[0][N-1]<<endl; else cout<<"inf"<<endl; return 0; }
a.cc: In function 'int main()': a.cc:31:54: error: no matching function for call to 'min(long int, long long int)' 31 | dis[i][j]=min(Inf,dis[i][k]+dis[k][j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: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:31:54: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 31 | dis[i][j]=min(Inf,dis[i][k]+dis[k][j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /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: /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:31:54: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 31 | dis[i][j]=min(Inf,dis[i][k]+dis[k][j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
s577508183
p03722
C++
#include <bits/stdc++.h> using namespace std; #if __has_include("print.hpp") #include "print.hpp" #endif #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() typedef long long ll; typedef pair<int, int> p; vector<ll> x(1010); void x_init(){ x[0] = 0; for (int i = 1; i < 1010; i++) { x[i] = -LLONG_MAX; } } set<int> use; ll n, m; vector<int> A; vector<int> B; vector<int> C; void dfs(int from, set<int> tmp){ // print(tmp); // cout << from << endl; if(from == n-1){ use.insert(tmp.begin(), tmp.end()); return; } for (int i = 0; i < m; i++) { if(A[i] == from) { if(tmp.count(B[i]) == 1) return; tmp.insert(A[i]); tmp.insert(B[i]); dfs(B[i], tmp); tmp.erase(A[i]); tmp.erase(B[i]); } } return; } int main(){ cin >> n >> m; vector<int> a(m); vector<int> b(m); vector<int> c(m); for (int i = 0; i < m; i++) { cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--; } A = a; B = b; C = c; x_init(); set<int> tmp; dfs(0, tmp); print(use); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if(use.count(b[j]) == 1) x[b[j]] = max(x[b[j]], x[a[j]] + c[j]); } } // for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if(use.count(b[j]) == 1){ if(x[b[j]] != max(x[b[j]], x[a[j]] + c[j])){ // cout << x[b[j]] << endl; // cout << x[a[j]] + c[j] << endl; // print(x); cout << "inf" << endl; return 0; } } } // } cout << x[n-1] << endl; }
a.cc: In function 'int main()': a.cc:72:3: error: 'print' was not declared in this scope; did you mean 'rint'? 72 | print(use); | ^~~~~ | rint
s798627230
p03722
C++
#include <iostream> using namespace std; struct edge{ int from, to, cost; }; const int MAX_E = 1e3; const int MAX_V = 1e6; edge e[MAX_E]; long long d[MAX_V]; int V, E; int main(){ cin >> V >> E; for (int i = 0; i < E; ++i){ int a, b, c; cin >> a >> b >> c; e[i] = edge{a,b,c}; } for (int i = 1; i <= V; ++i) d[i] = LLONG_MIN; d[1] = 0; bool update; for (int i = 0; i <= V; ++i){ update = false; for (int j = 0; j < E; j++){ edge _e = e[j]; if (d[_e.to] < d[_e.from] + _e.cost){ d[_e.to] = d[_e.from] + _e.cost; update = true; } } if (!update) { break; } } if (!update){ cout << d[V] << endl; }else{ cout << "inf" << endl; } }
a.cc: In function 'int main()': a.cc:21:41: error: 'LLONG_MIN' was not declared in this scope 21 | for (int i = 1; i <= V; ++i) d[i] = LLONG_MIN; | ^~~~~~~~~ a.cc:2:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include <iostream> +++ |+#include <climits> 2 | using namespace std;
s779707319
p03722
C++
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int N, M; cin >> N >> M; vector<int> a(M), b(M), c(M); for (int i = 0; i < M; i++) { cin >> a[i] >> b[i]>> c[i]; --a[i], --b[i]; } vector<int> dist(N, -1e18); dist[0] = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (dist[a[j]] == -inf) continue; if (dist[a[j]] + c[j] <= dist[b[j]]) continue; dist[b[j]] = dist[a[j]] + c[j]; if (i == N - 1 && b[j] == N - 1) return cout << "inf" << endl, 0; } } cout << dist[N - 1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:32: error: 'inf' was not declared in this scope; did you mean 'ynf'? 19 | if (dist[a[j]] == -inf) continue; | ^~~ | ynf
s445157642
p03722
C++
#include <iostream> #include <algorithm> #include <vector> #include <utility> #include <cstring> typedef long long ll; #define MAX_V 10000 const ll INF = 1LL << 50; using namespace std; struct edge{ ll from,to,cost; }; edge es[MAX_V]; ll d[MAX_V]; bool neg[MAX_V]; int V,E; void Bellman_Ford(int s){ for(int i=0;i<=V;i++)d[i]=INF; d[s]=0; ll cnt = 0; while(true){ cnt++; bool update = false; for(int i=0;i<E;i++){ edge e = es[i]; if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){ d[e.to] = d[e.from] + e.cost; update = true; } } if(!update)break; if(cnt==V)return; } } bool find_negative_loop(){ memset(neg,0,sizeof(neg)); for(int i=0;i<V;i++){ for(int j = 0; j < E;j++){ edge e = es[j]; if(d[e.to] > d[e.from] + e.cost){ d[e.to] = d[e.from] + e.cost; neg[e.to]=true; if(i==V-1)return true; } if(neg[e.from])neg[e.to] = true; } } return false; } int main(){ cin >> V >> E; ll a,b,c; for(int i=0;i<E;i++){ cin >> a >> b >> c; es[i].from = a-1; es[i].to = b-1; es[i].cost = -1*c; } bool ch; Bellman_Ford(0); ll ret = -neg[V-1] ch=find_negative_loop(); if(neg[V-1])cout << "inf" << endl; else cout << ret << endl; return 0; }
a.cc: In function 'int main()': a.cc:68:3: error: expected ',' or ';' before 'ch' 68 | ch=find_negative_loop(); | ^~
s732257009
p03722
C++
#include <iostream> #include <algorithm> #include <vector> #include <utility> #include <cstring> typedef long long ll; #define MAX_V 10000 const ll INF = 1LL << 50; using namespace std; struct edge{ ll from,to,cost; }; edge es[MAX_V]; ll d[MAX_V]; bool neg[MAX_V]; int V,E; void Bellman_Ford(int s){ for(int i=0;i<=V;i++)d[i]=INF; d[s]=0; ll cnt = 0; while(true){ cnt++; bool update = false; for(int i=0;i<E;i++){ edge e = es[i]; if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){ d[e.to] = d[e.from] + e.cost; update = true; } } if(!update)break; if(cnt==V)return; } } void find_negative_loop(){ memset(neg,0,sizeof(neg)); for(int i=0;i<V;i++){ for(int j = 0; j < E;j++){ edge e = es[j]; if(d[e.to] > d[e.from] + e.cost){ d[e.to] = d[e.from] + e.cost; neg[e.to]=true; if(i==V-1)return true; } if(neg[e.from])neg[e.to] = true; } } return false; } int main(){ cin >> V >> E; ll a,b,c; for(int i=0;i<E;i++){ cin >> a >> b >> c; es[i].from = a-1; es[i].to = b-1; es[i].cost = -1*c; } bool ch; Bellman_Ford(0); ll ret = -neg[V-1] ch=find_negative_loop(); if(neg[V-1])cout << "inf" << endl; else cout << ret << endl; return 0; }
a.cc: In function 'void find_negative_loop()': a.cc:48:26: error: return-statement with a value, in function returning 'void' [-fpermissive] 48 | if(i==V-1)return true; | ^~~~ a.cc:53:10: error: return-statement with a value, in function returning 'void' [-fpermissive] 53 | return false; | ^~~~~ a.cc: In function 'int main()': a.cc:68:3: error: expected ',' or ';' before 'ch' 68 | ch=find_negative_loop(); | ^~
s267510173
p03722
C++
def bellman_ford(N, M, edge): d = [10 ** 100] * N d[0] = 0 infFlag = False for count in range(N + 1): for i in range(M): if d[edge[i][0]] + edge[i][2] < d[edge[i][1]]: d[edge[i][1]] = d[edge[i][0]] + edge[i][2] if count == N and edge[i][1] == N - 1: infFlag = True return infFlag, -d[N - 1] def main(): N, M = map(int, input().split()) edge = [] for i in range(M): a, b, c = map(int, input().split()) edge.append([a - 1, b - 1, -c]) infFlag, ans = bellman_ford(N, M, edge) if infFlag: print('inf') else: print(ans) if __name__ == '__main__': main()
a.cc:22:15: warning: multi-character character constant [-Wmultichar] 22 | print('inf') | ^~~~~ a.cc:27:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 27 | if __name__ == '__main__': | ^~~~~~~~~~ a.cc:1:1: error: 'def' does not name a type 1 | def bellman_ford(N, M, edge): | ^~~
s839561273
p03722
C++
#include<bits/stdc++.h> using namespace std; struct edge{long to,cost;}; typedef pair<long,long> P; vector<edge> g[1010]; long d[1010]; bool mugen = false; long n,m,kekka = -1000000000000000; int cou[1010]; long inf = 1000000000000000; void dfs(long s,long p){ //cout << s << " " << p << " " << p-d[s] << endl; if(s == 1){ cou++; } if(d[s] != inf){ if(p - d[s] > 0 && s != 1){ mugen = true; return; } if(s == 1 && cou > 1 && p - d[1] > 0){ mugen = true; return; } } d[s] = p; if(s == n){ kekka = max(kekka,p); return; } for(int i = 0;i < g[s].size();i++){ dfs(g[s][i].to,p + g[s][i].cost); } } int main(){ cin >> n >> m; for(int i = 0;i <= n;i++){ d[i] = inf; } d[1] = 0; for(int i = 1;i <= m;i++){ edge k; long a; cin >> a >> k.to >> k.cost; g[a].push_back(k); } dfs(1,0); if(mugen == true){ cout << "inf" << endl; } else{ cout << kekka << endl; } }
a.cc: In function 'void dfs(long int, long int)': a.cc:16:5: error: lvalue required as increment operand 16 | cou++; | ^~~ a.cc:23:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 23 | if(s == 1 && cou > 1 && p - d[1] > 0){ | ~~~~^~~
s515256366
p03722
C++
(eval-when (:compile-toplevel :load-toplevel :execute) (defparameter OPT #+swank '(optimize (speed 3) (safety 2)) #-swank '(optimize (speed 3) (safety 0) (debug 0))) #+swank (progn (ql:quickload '(:cl-debug-print :fiveam)) (shadow :run) (use-package :fiveam))) #+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax) ;; BEGIN_INSERTED_CONTENTS (defmacro split-ints-and-bind (vars string &body body) (let ((pos1 (gensym "POS")) (pos2 (gensym "POS")) (str (gensym "STR"))) (labels ((expand (vars &optional (init-pos1 t)) (if (null vars) body `((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2))) (,pos2 (position #\space ,str :start ,pos1 :test #'char=)) (,(car vars) (parse-integer ,str :start ,pos1 :end ,pos2))) ,@(expand (cdr vars) nil)))))) `(let ((,str ,string)) (declare (string ,str)) ,@(expand vars))))) (defmacro define-int-types (&rest bits) `(progn ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits) ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits))) (define-int-types 2 4 7 8 15 16 31 32 62 63 64) (defmacro println (obj &optional (stream '*standard-output*)) `(let ((*read-default-float-format* 'double-float)) (prog1 (princ ,obj ,stream) (terpri ,stream)))) ;; Hauptteil (defun main () (let* ((n (read)) (m (read)) ;; (from to -cost) (edges (make-array m :element-type 'list)) (dp (make-array n :element-type 'fixnum :initial-element most-positive-fixnum))) (setf (aref dp 0) 0) (dotimes (i m) (split-ints-and-bind (a b c) (read-line) (setf (aref edges i) (list (- a 1) (- b 1) (- c))))) (println (loop repeat n unless (loop for (src dest neg-cost) across edges thereis (when (and (/= most-positive-fixnum (aref dp src)) (< (+ (aref dp src) neg-cost) (aref dp dest))) (setf (aref dp dest) (+ (aref dp src) neg-cost)))) do (return (- (aref dp (- n 1)))) finally (return "inf"))))) #-swank(main)
a.cc:3:6: error: invalid preprocessing directive #+ 3 | #+swank '(optimize (speed 3) (safety 2)) | ^ a.cc:3:13: warning: missing terminating ' character 3 | #+swank '(optimize (speed 3) (safety 2)) | ^ a.cc:4:6: error: invalid preprocessing directive #- 4 | #-swank '(optimize (speed 3) (safety 0) (debug 0))) | ^ a.cc:4:13: warning: missing terminating ' character 4 | #-swank '(optimize (speed 3) (safety 0) (debug 0))) | ^ a.cc:5:4: error: invalid preprocessing directive #+ 5 | #+swank (progn (ql:quickload '(:cl-debug-print :fiveam)) | ^ a.cc:5:32: warning: missing terminating ' character 5 | #+swank (progn (ql:quickload '(:cl-debug-print :fiveam)) | ^ a.cc:8:2: error: invalid preprocessing directive #+ 8 | #+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax) | ^ a.cc:18:20: error: stray '`' in program 18 | `((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2))) | ^ a.cc:18:53: error: stray '`' in program 18 | `((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2))) | ^ a.cc:19:46: error: stray '#' in program 19 | (,pos2 (position #\space ,str :start ,pos1 :test #'char=)) | ^ a.cc:19:47: error: stray '\' in program 19 | (,pos2 (position #\space ,str :start ,pos1 :test #'char=)) | ^ a.cc:19:78: error: stray '#' in program 19 | (,pos2 (position #\space ,str :start ,pos1 :test #'char=)) | ^ a.cc:19:79: warning: missing terminating ' character 19 | (,pos2 (position #\space ,str :start ,pos1 :test #'char=)) | ^ a.cc:19:79: error: missing terminating ' character 19 | (,pos2 (position #\space ,str :start ,pos1 :test #'char=)) | ^~~~~~~~ a.cc:21:25: error: stray '@' in program 21 | ,@(expand (cdr vars) nil)))))) | ^ a.cc:22:7: error: stray '`' in program 22 | `(let ((,str ,string)) | ^ a.cc:24:11: error: stray '@' in program 24 | ,@(expand vars))))) | ^ a.cc:27:3: error: stray '`' in program 27 | `(progn | ^ a.cc:28:7: error: stray '@' in program 28 | ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits) | ^ a.cc:28:28: error: stray '`' in program 28 | ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits) | ^ a.cc:28:75: warning: missing terminating ' character 28 | ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits) | ^ a.cc:28:75: error: missing terminating ' character 28 | ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:29:7: error: stray '@' in program 29 | ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits))) | ^ a.cc:29:28: error: stray '`' in program 29 | ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits))) | ^ a.cc:29:74: warning: missing terminating ' character 29 | ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits))) | ^ a.cc:29:74: error: missing terminating ' character 29 | ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:32:42: warning: missing terminating ' character 32 | (defmacro println (obj &optional (stream '*standard-output*)) | ^ a.cc:32:42: error: missing terminating ' character 32 | (defmacro println (obj &optional (stream '*standard-output*)) | ^~~~~~~~~~~~~~~~~~~~ a.cc:33:3: error: stray '`' in program 33 | `(let ((*read-default-float-format* 'double-float)) | ^ a.cc:33:39: warning: missing terminating ' character 33 | `(let ((*read-default-float-format* 'double-float)) | ^ a.cc:33:39: error: missing terminating ' character 33 | `(let ((*read-default-float-format* 'double-float)) | ^~~~~~~~~~~~~~~ a.cc:42:45: warning: missing terminating ' character 42 | (edges (make-array m :element-type 'list)) | ^ a.cc:42:45: error: missing terminating ' character 42 | (edges (make-array m :element-type 'list)) | ^~~~~~~ a.cc:43:42: warning: missing terminating ' character 43 | (dp (make-array n :element-type 'fixnum :initial-element most-positive-fixnum))) | ^ a.cc:43:42: error: missing terminating ' character 43 | (dp (make-array n :element-type 'fixnum :initial-element most-positive-fixnum))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:58:2: error: invalid preprocessing directive #- 58 | #-swank(main) | ^ a.cc:1:6: error: expected ')' before '-' token 1 | (eval-when (:compile-toplevel :load-toplevel :execute) | ~ ^ | ) a.cc:11:1: error: expected constructor, destructor, or type conversion before '(' token 11 | (defmacro split-ints-and-bind (vars string &body body) | ^ a.cc:38:1: error: expected constructor, destructor, or type conversion before '(' token 38 | (defun main () | ^ a.cc:41:18: error: expected ')' before 'to' 41 | ;; (from to -cost) | ~ ^~~ | )
s995314900
p03722
C++
#include <iostream> #include <string> #include <vector> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> #include <map> #include <stack> #include <queue> #include <set> #include <cstring> using namespace std; // ascending order #define vsort(v) sort(v.begin(), v.end()) // descending order #define vsort_r(v) sort(v.begin(), v.end(), greater<int>()) #define vunique(v) unique(v.begin(), v.end()) #define mp make_pair #define ts(x) to_string(x) #define rep(i, a, b) for(int i = (int)a; i < (int)b; i++) #define repm(i, a, b) for(int i = (int)a; i > (int)b; i--) #define bit(a) bitset<8>(a) #define des_priority_queue priority_queue<int, vector<int>, greater<int> > typedef long long ll; typedef pair<int, int> P; const ll INF = 1e18; #define MAX_E 2010 #define MAX_V 1010 struct edge { ll from, to, cost; }; ll d[MAX_V]; int V, E; edge es[MAX_E]; void shortest_path(int s) { rep(i, 0, V) d[i] = INF; d[s] = 0; while(true) { bool update = false; rep(i, 0, E) { edge e = es[i]; if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; update = true; } } if(!update) break; } } bool find_negative_loop(int s) { //memset(d, 0, sizeof(d)); fill(d, d + V, INF); d[s] = 0; rep(i, 0, V) { rep(j, 0, E) { edge e = es[j]; if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; if(i == V - 1 and e.to = V - 1) return true; } } } return false; } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> V >> E; rep(i, 0, E) { int s, t, d; cin >> s >> t >> d; es[i].from = --s; es[i].to = --t; es[i].cost = -d; } if(find_negative_loop(0)) { cout << "inf" << endl; return 0; } if(d[V - 1] != INF) cout << -d[V - 1] << endl; else cout << "inf" << endl; }
a.cc: In function 'bool find_negative_loop(int)': a.cc:66:47: error: lvalue required as left operand of assignment 66 | if(i == V - 1 and e.to = V - 1) return true; | ~~~~~~~~~~~^~~~~~~~
s465392384
p03722
C++
#include <iostream> #include <string> #include <vector> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> #include <map> #include <stack> #include <queue> #include <set> #include <cstring> using namespace std; // ascending order #define vsort(v) sort(v.begin(), v.end()) // descending order #define vsort_r(v) sort(v.begin(), v.end(), greater<int>()) #define vunique(v) unique(v.begin(), v.end()) #define mp make_pair #define ts(x) to_string(x) #define rep(i, a, b) for(int i = (int)a; i < (int)b; i++) #define repm(i, a, b) for(int i = (int)a; i > (int)b; i--) #define bit(a) bitset<8>(a) #define des_priority_queue priority_queue<int, vector<int>, greater<int> > typedef long long ll; typedef pair<int, int> P; const ll INF = 1e18; #define MAX_E 2010 #define MAX_V 1010 struct edge { ll from, to, cost; }; ll d[MAX_V]; int V, E; edge es[MAX_E]; void shortest_path(int s) { rep(i, 0, V) d[i] = INF; d[s] = 0; while(true) { bool update = false; rep(i, 0, E) { edge e = es[i]; if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; update = true; } } if(!update) break; } } bool find_negative_loop(int s) { //memset(d, 0, sizeof(d)); fill(d, d + V, INF); d[s] = 0; rep(i, 0, V) { rep(j, 0, E) { edge e = es[j]; if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; if(i == V - 1 and e.to = V - 1) return true; } } } return false; } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> V >> E; rep(i, 0, E) { int s, t, d; cin >> s >> t >> d; es[i].from = --s; es[i].to = --t; es[i].cost = -d; } if(find_negative_loop(0)) { cout << "inf" << endl; return 0; } if(d[V - 1] != INF) cout << -d[V - 1] << endl; else cout << "inf" << endl; }
a.cc: In function 'bool find_negative_loop(int)': a.cc:66:47: error: lvalue required as left operand of assignment 66 | if(i == V - 1 and e.to = V - 1) return true; | ~~~~~~~~~~~^~~~~~~~
s200728210
p03722
C++
// Template #include <iostream> #include <string> #include <vector> #include <utility> #include <functional> #include <numeric> #include <list> #include <set> #include <map> #include <algorithm> #include <cmath> using namespace std; const int MOD = 1000000007; #define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end() #define s_exists(elem, s) s.find(elem)!=s.end() #define mod_mul(x, y) x*y%MOD #define mod_add(x, y) (x+y)%MOD #define mod_sub(x, y) (x-y)%MOD #define REP(i, n) for(int i = 0;i < n;i++) #define INF 1LL << 50 long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } long lcm( long m, long n ){ if ( ( 0 == m ) || ( 0 == n ) ) return 0; return ((m / gcd(m, n)) * n); } struct edge{int from,to; long long cost;}; std::vector<edge> edges; long long d[1000]; int main(){ int N,M; cin >> N >> M; REP(i, M){ int a,b; cin >> a >> b; long long c; cin >> c; edge e = {a-1,b-1,-1LL*c}; edges.push_back(e); } for(int i=0; i<1000; i++){ dist[i] = INF; } d[0] = 0LL; bool terminate = true; REP(i, N){ REP(j, edges.size()){ edge e = edges[j]; if(d[e.to] > d[e.from]+e.cost){ d[e.to]=d[e.from]+e.cost; if(i == N-1){ terminate = false; } } } } if(terminate) cout << -1*d[N-1] << endl; else cout << "inf" << endl; return 0; }
a.cc: In function 'int main()': a.cc:53:9: error: 'dist' was not declared in this scope 53 | dist[i] = INF; | ^~~~
s639361643
p03722
C++
#include <bits/stdc++.h> #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define eps LDBL_EPSILON #define moder 1000000007 #define int long long #define ll long long #define INF LLONG_MAX/3 #define P std::pair<int,int> #define prique priority_queue<int,vector<int>,greater<int>> using namespace std; struct edge{int from,to,cost;}; int n,m,a,b,c,d[1010]; vector<edge> vec; void bf(int s){ for(int i=1;i<=n;i++)d[i]=INF; d[s]=0; while(true){ bool update=false; for(edge e:vec){ if(d[e.from]==INF)continue; if(d[e.to]>d[e.from]+e.cost){ d[e.to]=d[e.from]+e.cost; update=true; } } if(!update)break; } } bool check(){ memset(d,0,sizeof(d)); int cnt=0; while(true){ for(edge e:vec){ if(d[e.to]>d[e.from]+e.cost){ d[e.to]=d[e.from]+e.cost; if(i>=n-1)return true; } } cnt++; } return false; } signed main(){ cin>>n>>m; rep(i,m){ cin>>a>>b>>c; vec.push_back({a,b,-c}); } if(check())cout<<"inf"<<endl; else{ bf(1); cout<<-d[n]<<endl; } return 0; }
a.cc: In function 'bool check()': a.cc:36:36: error: 'i' was not declared in this scope 36 | if(i>=n-1)return true; | ^
s156626553
p03722
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,m;cin>>n>>m; ll in=-10000000000; ll a[m],b[m],c[m]; vector<pair<ll,ll>>list[n+1]; for(ll i=0;i<m;i++){ cin>>a[i]>>b[i]>>c[i]; list[a[i]].push_back(make_pair(b[i],c[i])); } ll score[n+1]; //cout<<list[1][1].first<<list[1][1].second<<endl;return 0; for(ll i=0;i<=n;i++)score[i]=in; score[1]=0; ll ans; for(ll i=0;i<3*n;i++){ bool update=false; for(ll j=0;j<m;j++){ if(score[a[j]]!=in){ if(score[b[j]]<score[a[j]]+c[j]){ score[b[j]]=score[a[j]]+c[j]; } } } } if(i==n-2)ans=score[n]; if(i>=n-1&&score[n]>ans){ cout<<"inf"<<endl; return 0; } } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:30:8: error: 'i' was not declared in this scope 30 | if(i==n-2)ans=score[n]; | ^ a.cc:31:10: error: 'i' was not declared in this scope 31 | if(i>=n-1&&score[n]>ans){ | ^ a.cc: At global scope: a.cc:37:3: error: 'cout' does not name a type 37 | cout<<ans<<endl; | ^~~~ a.cc:38:1: error: expected declaration before '}' token 38 | } | ^
s623964087
p03722
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,m;cin>>n>>m; ll in=-10000000000; ll a[m],b[m],c[m]; vector<pair<ll,ll>>list[n+1]; for(ll i=0;i<m;i++){ cin>>a[i]>>b[i]>>c[i]; list[a[i]].push_back(make_pair(b[i],c[i])); } ll score[n+1]; //cout<<list[1][1].first<<list[1][1].second<<endl;return 0; for(ll i=0;i<=n;i++)score[i]=in; score[1]=0; for(ll i=0;i<n-1;i++){ for(ll j=1;j<=n;j++){ if(score[j]!=in){ for(ll k=0;k<list[j].size();k++){ ll f=list[j][k].first; ll s=list[j][k].second; if(score[f]<score[j]+s){ score[f]=score[j]+s; } } } } } bool update[n+1]; for(ll i=0;i<=n;i++)update[i]=false; for(ll i=0;i<n;i++){ for(ll j=1;j<=n;j++){ if(score[j]!=in){ for(ll k=0;k<list[j].size();k++){ ll f=list[j][k].first; ll s=list[j][k].second; if(score[f]<score[j]+s){ score[f]=score[j]+s; update[f]=true; } if(update[j]){ for(ll p=0;p<list[j].size();p++){ update[list[j][p]]=true; } } } } } } if(update[n]){ cout<<"inf"<<endl; return 0; } cout<<score[n]<<endl; }
a.cc: In function 'int main()': a.cc:46:21: error: no match for 'operator[]' (operand types are 'bool [(n + 1)]' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'}) 46 | update[list[j][p]]=true; | ^
s959776933
p03722
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,m;cin>>n>>m; ll in=-10000000000; ll a[m],b[m],c[m]; vector<pair<ll,ll>>list[n+1]; for(ll i=0;i<m;i++){ cin>>a[i]>>b[i]>>c[i]; list[a[i]].push_back(make_pair(b[i],c[i])); } ll score[n+1]; //cout<<list[1][1].first<<list[1][1].second<<endl;return 0; for(ll i=0;i<=n;i++)score[i]=in; score[1]=0; for(ll i=0;i<n-1;i++){ for(ll j=1;j<=n;j++){ if(score[j]!=in){ for(ll k=0;k<list[j].size();k++){ ll f=list[j][k].first; ll s=list[j][k].second; if(score[f]<score[j]+s){ score[f]=score[j]+s; } } } } } bool update[n+1]; for(ll i=0;i<=n;i++)update[i]=false; for(ll i=0;i<n;i++){ for(ll j=1;j<=n;j++){ if(score[j]!=in){ for(ll k=0;k<list[j].size();k++){ ll f=list[j][k].first; ll s=list[j][k].second; if(score[f]<score[j]+s){ score[f]=score[j]+s; update[f]=true; } } } } } if(update[n]){ cout<<"inf"<<endl; return 0; } } } cout<<score[n]<<endl; }
a.cc:53:3: error: expected declaration before '}' token 53 | } | ^ a.cc:54:3: error: 'cout' does not name a type 54 | cout<<score[n]<<endl; | ^~~~ a.cc:55:1: error: expected declaration before '}' token 55 | } | ^
s849138065
p03722
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define MIN -100000000000000000 #define INF 100000000000000000 ll n,m; bool ab; vector<ll> d; vector<ll> b; vector<vector<ll>> a,c; void daiku(ll i){ b[i]++; for(ll j:a[i]){ if(c[i][j]+d[i]>d[j]){ if(b[j]<1){ d[j]=c[i][j]+d[i]; daiku(j); }else{ ab=true; } } } b[i]=0; } int main(){ cin>>n>>m; n++; a.resize(n); b.resize(n); d.resize(n); c.resize(n); for(int i=0;i<n;i++){ b[i]=0; c[i].resize(n); d[i]=MIN; } for(int i=0;i<m;i++){ ll aa,bb,cc; cin>>aa>>bb>>cc; a[aa].push_back(bb); c[aa][bb]=cc; } d[1]=0; ab=false; daiku(1); if(ab) cout<<"inf"; else cout<<ma; }
a.cc: In function 'int main()': a.cc:49:11: error: 'ma' was not declared in this scope; did you mean 'm'? 49 | cout<<ma; | ^~ | m
s151135176
p03722
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define MIN -100000000000000000 #define INF 100000000000000000 ll n,m,; vector<ll> d; vector<ll> b; vector<vector<ll>> a,c; void daiku(ll i){ b[i]++; for(ll j:a[i]){ if(c[i][j]+d[i]>d[j]){ if(b[j]<1){ d[j]=c[i][j]+d[i]; daiku(j); } } } b[i]=0; } void ddaiku(ll i){ b[i]++; for(ll j:a[i]){ if(c[i][j]+d[i]>d[j]){ if(b[j]<10){ d[j]=c[i][j]+d[i]; ddaiku(j); } } } b[i]=0; } int main(){ cin>>n>>m; n++; a.resize(n); b.resize(n); d.resize(n); c.resize(n); for(int i=0;i<n;i++){ b[i]=0; c[i].resize(n); d[i]=MIN; } for(int i=0;i<m;i++){ ll aa,bb,cc; cin>>aa>>bb>>cc; a[aa].push_back(bb); c[aa][bb]=cc; } d[1]=0; daiku(1); ll ma=d[n-1]; for(int i=0;i<n;i++){ d[i]=MIN; } d[1]=0; ddaiku(1); if(ma<d[n-1]) cout<<"inf"; else cout<<ma; }
a.cc:6:8: error: expected unqualified-id before ';' token 6 | ll n,m,; | ^
s567890453
p03722
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define MIN -100000000000000000 #define INF 100000000000000000 ll n,m; vector<ll> d,dd; vector<ll> b; vector<vector<ll>> a,c; void daiku(ll i){ b[i]++; for(ll j:a[i]){ if(c[i][j]+d[i]>d[j]){ if(b[i]<1){ d[j]=c[i][j]+d[i]; daiku(j); } } } b[i]=0; } void ddaiku(ll i){ b[i]++; for(ll j:a[i]){ if(c[i][j]+dd[i]>dd[j]){ if(b[i]<2){ dd[j]=c[i][j]+dd[i]; daiku(j); } } } b[i]=0; } int main(){ cin>>n>>m; n++; a.resize(n); b.resize(n); d.resize(n); dd.resize(n); c.resize(n); for(int i=0;i<n;i++){ b[i]=0; c[i].resize(n); d[i]=MIN; dd[i]=MIN; } for(int i=0;i<m;i++){ ll aa,bb,cc; cin>>aa>>bb>>cc; a[aa].push_back(bb); c[aa][bb]=cc; } cnt=0; d[1]=0; daiku(1); dd[1]=0; ddaiku(1); if(d[n-1]<dd[n-1]) cout<<"inf"; else cout<<d[n-1]; }
a.cc: In function 'int main()': a.cc:54:3: error: 'cnt' was not declared in this scope; did you mean 'int'? 54 | cnt=0; | ^~~ | int
s650880153
p03722
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double dd; const int INF = 1e9; int n, m; vector<map<int,ll>> mp(1001); bool used[1001] = {}; bool if_inf = false; ll ans = -1e18; void dfs(int k, ll dd) { if (used[k]) { if_inf = true; return; } if (k == n) { ans = max(ans, dd); } used[k] = true; for (auto p& : mp[k]) { if (used[p.first]) { if_inf = true; break; } dfs(p.first, dd + p.second); } if (if_inf) return; used[k] = false; } int main(){ cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; ll c; cin >> a >> b >> c; mp[a][b] = c; } dfs(1, 0); if (if_inf) cout << "inf" << endl; else cout << ans << endl; return 0; }
a.cc: In function 'void dfs(int, ll)': a.cc:22:14: error: expected ';' before '&' token 22 | for (auto p& : mp[k]) { | ^ | ; a.cc:22:16: error: expected primary-expression before ':' token 22 | for (auto p& : mp[k]) { | ^ a.cc:22:15: error: expected ';' before ':' token 22 | for (auto p& : mp[k]) { | ^~ | ; a.cc:22:16: error: expected primary-expression before ':' token 22 | for (auto p& : mp[k]) { | ^ a.cc:22:15: error: expected ')' before ':' token 22 | for (auto p& : mp[k]) { | ~ ^~ | ) a.cc:22:16: error: expected primary-expression before ':' token 22 | for (auto p& : mp[k]) { | ^
s009644886
p03722
C++
#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; // #define int long long #define ALL(x) (x).begin(), (x).end() #define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end()); #define m0(x) memset((x), 0, sizeof(x)) #define mm(x) memset((x), -1, sizeof(x)) // bit_macro #define bit(n) (1LL << (n)) #define bitset(a, b) (a) |= (1 << (b)) #define bitunset(a, b) (a) |= ~(1 << (b)) #define bitcheck(a, b) ((a) >> (b)) & 1 #define bitcount(a) __builtin_popcountll((a)) // typedef long long lint; typedef pair<int, int> P; typedef tuple<int, int, int> TP; typedef vector<int> vec; typedef vector<vec> mat; // const int INF = (int)1e18; const int MOD = (int)1e9 + 7; const double EPS = (double)1e-10; const int dx[] = {-1, 0, 0, 1}; const int dy[] = {0, -1, 1, 0}; // template <typename T> void chmax(T &a, T b) { a = max(a, b); } template <typename T> void chmin(T &a, T b) { a = min(a, b); } // struct Accelerate_Cin { Accelerate_Cin() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); }; }; const int MAX_E = 2001; const int MAX_V = 1001; //O(|V||E|) //単一始点最短経路(負の経路があってもよい) //頂点fromから頂点toへのコストcostの辺 struct edge { int from, to, cost; }; edge es[MAX_E]; //辺 int d[MAX_V]; //最短距離 int V, E; // Vは頂点数、Eは辺数 bool check[MAX_V]; // s番目の頂点から各頂点への最短距離を求める。 void shortest_path(int s) { for (int i = 0; i < V; i++) d[i] = INF; d[s] = 0; while (true) { bool update = false; for (int i = 0; i < E; i++) { edge e = es[i]; if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; update = true; } } if (!update) break; } } // trueなら負の経路が存在する bool find_negative_loop() { memset(d, 0, sizeof(d)); memset(check, 0, sizeof(check)); for (int i = 0; i <= V + 10; i++) { for (int j = 0; j < E; j++) { edge e = es[j]; if (d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; if (i == V) { check[e.to] = true; check[e.from] = true; } if (i == V + 5) { return true; } } } } return false; } signed main() { cin >> V >> E; for (int i = 0; i < E; i++) { int a, b, c; cin >> a >> b >> c; a--, b--; es[i] = edge{a, b, -c}; } if (find_negative_loop()) { if (check[V - 1]) { cout << "inf" << end5l; return 0; } } shortest_path(0); cout << -d[V - 1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:110:24: error: 'end5l' was not declared in this scope 110 | cout << "inf" << end5l; | ^~~~~
s938376361
p03722
Java
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; class Main{ static int[][] map ; static long INF =Long.MAX_VALUE/2; static int n,m ; static long[] dis; public static void main(String[] args) { Scanner sc = new Scanner(System.in); //文字の入力 n = sc.nextInt(); m = sc.nextInt(); Edge[] v = new Edge[m]; for(int i = 0;i < m;i++){ v[i]=new Edge(); v[i].from=sc.nextInt(); v[i].to=sc.nextInt(); v[i].cost=-sc.nextInt(); //ベルマンフォードを使うためにわざとマイナスにしている } dis = new long[n+1]; Arrays.fill(dis, INF); boolean flag = false; long ans = 0; int count = 0; while(flag){ flag = false; for(int i = 0;i < m;i++){ if(dis[v[i].from] + v[i].cost < dis[v[i].to]){ dis[v[i].to]=dis[v[i].from]+v[i].cost; flag= true; } } if(count == n){ ans = dis[n]; } if(count == 2*n){ //閉路に入った時 if(ans > dis[n]){ //閉路がプラスループ System.out.println("inf"); return; }else{ //閉路がマイナスループ System.out.println(-dis[n]); return; } } count++; if(!flag){ //更新なしだったらループ出る break; } System.out.println(-dis[n]); } for(int i = 1;i <= n;i++){ if( map[n][i] > 0){ //道があったら if(map[i][n] > 0){ System.out.println("inf"); System.exit(0); }else if(map[i][n] < 0){ if(map[n][i] + map[i][n] > 0){ System.out.println("inf"); System.exit(0); } } }else if(map[n][i] < 0){ if(map[i][n] > 0 && map[i][n] + map[n][i] > 0){ System.out.println("inf"); System.exit(0); } } } dfs(1,0); System.out.println(ans); } static void dfs(int p,long score){ if(p == n){ ans = Math.max(ans,score); } for(int i = 1;i <= n;i++){ if( map[p][i] != 0){ //道があったら dfs(i, score+ map[p][i]); } } return; } } class Edge{ int to; int from; int cost; } class MyComparator implements Comparator { public int compare(Object obj1, Object obj2) { int num1 = (int)obj1; int num2 = (int)obj2; if(num1 < num2) { return 1; } else if(num1 > num2) { return -1; } else{ return 0; } } }
Main.java:103: error: cannot find symbol ans = Math.max(ans,score); ^ symbol: variable ans location: class Main Main.java:103: error: cannot find symbol ans = Math.max(ans,score); ^ symbol: variable ans location: class Main 2 errors
s517726142
p03722
C++
inf = int(1e20) node,edge = map(int,input().split()) ed = [] for e in range(edge): ed.append(e[0]-1,e[1]-1,-e[2]) start = 0 goal = node-1 d = [inf for i in range(node)] pre = [inf for i in range(node)] d[start] = 0 for i in range(node): update = False for e in ed: if d[e[0]] != inf and d[e[1]]>d[e[0]]+e[2]: d[e[1]] = d[e[0]]+e[2] update = True pre[e[1]] = e[0] if update==False: print(-d[goal]) break else: nowcos = d[goal] for i in range(node): for e in ed: if d[e[0]] != inf and d[e[1]]>d[e[0]]+e[2]: d[e[1]] = d[e[0]]+e[2] pre[e[1]] = e[0] if nowcos != d[goal]: print('inf') else: print(-d[goal])
a.cc:33:15: warning: multi-character character constant [-Wmultichar] 33 | print('inf') | ^~~~~ a.cc:1:1: error: 'inf' does not name a type; did you mean 'int'? 1 | inf = int(1e20) | ^~~ | int
s158184856
p03722
C++
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define REP(i, n) FOR(i,0,n) #define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--) #define IREP(i, n) IFOR(i,0,n) #define SORT(a) sort(a.begin(), a.end()) #define REVERSE(a) reverse(a.begin(), a.end()) #define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x)) #define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x)) #define int long long #define INF 1000000000000000000 using namespace std; typedef vector<int> vec; typedef vector<vec> mat; typedef pair<int, int> Pii; template<typename T> void readvec(vector<T> &a); void readindex(vector<int> &a); struct edge{int to, cost;}; class Graph { public: int V; vector<vector<edge>> G; vec d, root; Graph(int V): V(V){ G = vector<vector<edge>>(V, vector<edge>(0)); d = vec(V); root = vec(V); } void add_edge(int from, int to, int cost){ G[from].push_back(edge({to, cost})); } void add_edge2(int v1, int v2, int cost){ add_edge(v1, v2, cost); add_edge(v2, v1, cost); } void erase_edge(int from, int to){ vec e(0); REP(i, G[from].size()){ if(G[from][i].to == to) e.push_back(i); } IREP(i, e.size()) G[from].erase(G[from].begin() + e[i]); } void erase_edge2(int v1, int v2){ erase_edge(v1, v2); erase_edge(v2, v1); } void dijkstra(int s, int t){ priority_queue<Pii, vector<Pii>, greater<Pii>> que; fill(d.begin(), d.end(), INF); d[s] = 0; que.push(Pii(0, s)); while(!que.empty()){ Pii p = que.top(); que.pop(); int v = p.second; if(v == t) return; if(d[v] < p.first) continue; REP(i, G[v].size()){ edge e = G[v][i]; if(d[e.to] > d[v] + e.cost){ d[e.to] = d[v] + e.cost; que.push(Pii(d[e.to], e.to)); } } } } void dijkstra_r(int s, int t){ priority_queue<Pii, vector<Pii>, greater<Pii>> que; fill(d.begin(), d.end(), INF); d[s] = 0; root[s] = -1; que.push(Pii(0, s)); while(!que.empty()){ Pii p = que.top(); que.pop(); int v = p.second; if(v == t) return; if(d[v] < p.first) continue; REP(i, G[v].size()){ edge e = G[v][i]; if(d[e.to] > d[v] + e.cost){ d[e.to] = d[v] + e.cost; root[e.to] = v; que.push(Pii(d[e.to], e.to)); } } } } bool bellman_ford(int s){ fill(d.begin(), d.end(), INF); d[s] = 0; REP(t, V){ bool update = false; REP(v, V){ REP(i, G[v].size()){ edge e = G[v][i]; if(d[v] != INF && d[e.to] > d[v] + e.cost){ d[e.to] = d[v] + e.cost; update = true; } } } if(t == V - 1 && update) return false; } return true; } mat waeshall_floyd(){ mat d2(V, vec(V)); REP(i, V){ REP(j, V){ if(i == j){ d2[i][j] = 0; }else{ d2[i][j] = INF; } } } REP(v, V){ REP(i, G[v].size()){ edge e = G[v][i]; d2[v][e.to] = e.cost; } } REP(k, V){ REP(i, V){ REP(j, V){ d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]); } } } return d2; } }; signed main(){ int N, M; cin >> N >> M; Graph G(N); int a, b, c; REP(i, M){ cin >> a >> b >> c; G.add_edge(a - 1, b - 1, -1 * c); } /* if(G.bellman_ford(0)){ cout << -1 * G.d[N - 1]; }else{ cout << "inf"; }*/ G.bellman_ford(0) cout << -1 * G.d[N - 1]; return 0; } template<typename T> void readvec(vector<T> &a){ REP(i, a.size()){ cin >> a[i]; } } void readindex(vector<int> &a){ REP(i, a.size()){ cin >> a[i]; a[i]--; } }
a.cc: In function 'int main()': a.cc:166:22: error: expected ';' before 'cout' 166 | G.bellman_ford(0) | ^ | ; 167 | cout << -1 * G.d[N - 1]; | ~~~~
s148390636
p03722
C++
void solve(istream &ccin = cin, ostream &ccout = cout) { ll n, m; ccin >> n >> m; vector<Edge> edges; rep(i, m) { ll a, b, c; ccin >> a >> b >> c; --a; --b; edges.emplace_back(a, b, -c); } ccout << "inf" << endl; } int main() { ios::sync_with_stdio(false); solve(); return 0; }
a.cc:1:6: error: variable or field 'solve' declared void 1 | void solve(istream &ccin = cin, ostream &ccout = cout) { | ^~~~~ a.cc:1:12: error: 'istream' was not declared in this scope 1 | void solve(istream &ccin = cin, ostream &ccout = cout) { | ^~~~~~~ a.cc:1:21: error: 'ccin' was not declared in this scope 1 | void solve(istream &ccin = cin, ostream &ccout = cout) { | ^~~~ a.cc:1:28: error: 'cin' was not declared in this scope 1 | void solve(istream &ccin = cin, ostream &ccout = cout) { | ^~~ a.cc:1:33: error: 'ostream' was not declared in this scope 1 | void solve(istream &ccin = cin, ostream &ccout = cout) { | ^~~~~~~ a.cc:1:42: error: 'ccout' was not declared in this scope 1 | void solve(istream &ccin = cin, ostream &ccout = cout) { | ^~~~~ a.cc:1:50: error: 'cout' was not declared in this scope 1 | void solve(istream &ccin = cin, ostream &ccout = cout) { | ^~~~ a.cc: In function 'int main()': a.cc:18:3: error: 'ios' has not been declared 18 | ios::sync_with_stdio(false); | ^~~ a.cc:19:3: error: 'solve' was not declared in this scope 19 | solve(); | ^~~~~
s010072828
p03722
C++
using System; using System.Collections.Generic; class Program{ static List<long>[] li; static int[] hf; static int k=0; static void Main(){ long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse); long[] h=new long[s[0]+1]; hf=new int[s[0]+1]; for(int i=1;i<=s[0];i++){h[i]=long.MinValue;} h[1]=0; long[][] arr=new long[s[1]][]; for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);} int l=0,z=0; bool b=true; while(b&&l<=s[0]){ l++; b=false; for(int i=0;i<s[1];i++){ if(h[arr[i][0]]!=long.MinValue&&h[arr[i][1]]<h[arr[i][0]]+arr[i][2]){ h[arr[i][1]]=h[arr[i][0]]+arr[i][2]; b=true; if(l==s[0]){hf[arr[i][1]]=1;z++;} } } } if(z>0){ li=new List<long>[s[0]+1]; for(int i=1;i<=s[0];i++){li[i]=new List<long>();} for(int i=0;i<s[1];i++){li[arr[i][1]].Add(arr[i][0]);} fu(s[0]); } Console.WriteLine("{0}",k>0?"inf":h[s[0]].ToString()); } static void fu(long n){ k+=hf[n]; hf[n]=2; for(int i=0;i<li[n].Count;i++){ if(hf[li[n][i]]<2){fu(li[n][i]);} } } }
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:4:16: error: 'List' does not name a type 4 | static List<long>[] li; | ^~~~ a.cc:5:19: error: expected unqualified-id before '[' token 5 | static int[] hf; | ^ a.cc:6:20: error: ISO C++ forbids in-class initialization of non-const static member 'Program::k' 6 | static int k=0; | ^ a.cc:44:2: error: expected ';' after class definition 44 | } | ^ | ; a.cc: In static member function 'static void Program::Main()': a.cc:8:21: error: structured binding declaration cannot have type 'long int' 8 | long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse); | ^~ a.cc:8:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:8:21: error: empty structured binding declaration a.cc:8:24: error: expected initializer before 's' 8 | long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse); | ^ a.cc:9:21: error: structured binding declaration cannot have type 'long int' 9 | long[] h=new long[s[0]+1]; | ^~ a.cc:9:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:9:21: error: empty structured binding declaration a.cc:9:24: error: expected initializer before 'h' 9 | long[] h=new long[s[0]+1]; | ^ a.cc:10:17: error: 'hf' was not declared in this scope 10 | hf=new int[s[0]+1]; | ^~ a.cc:10:28: error: 's' was not declared in this scope 10 | hf=new int[s[0]+1]; | ^ a.cc:11:42: error: 'h' was not declared in this scope 11 | for(int i=1;i<=s[0];i++){h[i]=long.MinValue;} | ^ a.cc:11:47: error: expected primary-expression before 'long' 11 | for(int i=1;i<=s[0];i++){h[i]=long.MinValue;} | ^~~~ a.cc:12:17: error: 'h' was not declared in this scope 12 | h[1]=0; | ^ a.cc:13:21: error: structured binding declaration cannot have type 'long int' 13 | long[][] arr=new long[s[1]][]; | ^~ a.cc:13:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:13:21: error: empty structured binding declaration a.cc:13:23: error: expected initializer before '[' token 13 | long[][] arr=new long[s[1]][]; | ^ a.cc:14:41: error: 'arr' was not declared in this scope 14 | for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);} | ^~~ a.cc:14:48: error: 'Array' was not declared in this scope 14 | for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);} | ^~~~~ a.cc:14:65: error: 'Console' was not declared in this scope 14 | for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);} | ^~~~~~~ a.cc:14:92: error: expected primary-expression before 'long' 14 | for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);} | ^~~~ a.cc:22:38: error: 'arr' was not declared in this scope 22 | if(h[arr[i][0]]!=long.MinValue&&h[arr[i][1]]<h[arr[i][0]]+arr[i][2]){ | ^~~ a.cc:22:50: error: expected primary-expression before 'long' 22 | if(h[arr[i][0]]!=long.MinValue&&h[arr[i][1]]<h[arr[i][0]]+arr[i][2]){ | ^~~~ a.cc:22:50: error: expected ')' before 'long' a.cc:22:35: note: to match this '(' 22 | if(h[arr[i][0]]!=long.MinValue&&h[arr[i][1]]<h[arr[i][0]]+arr[i][2]){ | ^ a.cc:30:25: error: 'li' was not declared in this scope; did you mean 'l'? 30 | li=new List<long>[s[0]+1]; | ^~ | l a.cc:30:32: error: 'List' does not name a type 30 | li=new List<long>[s[0]+1]; | ^~~~ a.cc:30:37: error: expected primary-expression before 'long' 30 | li=new List<long>[s[0]+1]; | ^~~~ a.cc:31:60: error: 'List' does not name a type 31 | for(int i=1;i<=s[0];i++){li[i]=new List<long>();} | ^~~~ a.cc:31:65: error: expected primary-expression before 'long' 31 | for(int i=1;i<=s[0];i++){li[i]=new List<long>();} | ^~~~ a.cc:32:52: error: 'arr' was not declared in this scope 32 | for(int i=0;i<s[1];i++){li[arr[i][1]].Add(arr[i][0]);} | ^~~ a.cc:35:17: error: 'Console' was not declared in this scope 35 | Console.WriteLine("{0}",k>0?"inf":h[s[0]].ToString()); | ^~~~~~~ a.cc: In static member function 'static void Program::fu(long int)': a.cc:38:20: error: 'hf' was not declared in this scope 38 | k+=hf[n]; | ^~ a.cc:40:31: error: 'li' was not declared in this scope; did you mean 'i'? 40 | for(int i=0;i<li[n].Count;i++){ | ^~ | i
s146436368
p03722
C++
#include<bits/stdc++.h> #define REP(i,s,n) for(int i=s;i<n;++i) #define rep(i,n) REP(i,0,n) #define ALL(x) x.begin(),x.end() #define EPS (1e-8) #define equals(a,b) (fabs((a)-(b))<EPS) using namespace std; typedef long long ll; typedef pair<int,int> ii; inline bool LT(double a,double b) { return !equals(a,b) && a < b; } inline bool LTE(double a,double b) { return equals(a,b) || a < b; } struct Edge { int to; ll w; }; int V,E; template<typename T> bool visit(const T& G,int v,vector<int>& order,vector<int>& color){ color[v] = 1; for(__typeof((G[v]).begin()) e = G[v].begin();e != G[v].end();e++){ if(color[e->to] == 2)continue; if(color[e->to] == 1)return false; if(!visit(G,e->to,order,color))return false; } order.push_back(v); color[v] = 2; return true; } template<typename T> bool topologicalSort(const T& G,vector<int>& order){ int SizeG = G.size(); vector<int> color(SizeG); for(int u=0;u<SizeG;u++) if(!color[u] && !visit(G,u,order,color)) return false; reverse(order.begin(),order.end()); return true; } vector<vector<Edge> > G; void init(int V) { G.resize(V,vector<Edge>()); } void add_edge(int s,int t,int c){ G[s].push_back((Edge){t,c}); } void compute() { } ll dp[1010]; int main() { cin >> V >> E; init(V); rep(i,E) { int a,b,c; cin >> a >> b >> c; --a, --b; add_edge(a,b,c); } rep(i,V) dp[i] = -LLONG_MAX; dp[0] = 0; vector<int> order; if( !topologicalSort(G,order) ) { puts("inf"); return 0; } rep(i,(int)order.size()) { int j = order[i]; rep(k,(int)G[j].size()) { int nex = G[j][k].to; ll cost = G[j][k].w; if( dp[j] == -LLONG_MAX ) continue; dp[nex] = max(dp[nex],dp[j]+cost); } }
a.cc: In function 'int main()': a.cc:88:4: error: expected '}' at end of input 88 | } | ^ a.cc:66:12: note: to match this '{' 66 | int main() { | ^
s052504607
p03722
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1LL << 50; int n, m; int a[2000], b[2000]; ll c[2000] ll dist[2000]; int main(){ cin >> n >> m; for (int i = 0; i < m; i++){ cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--; c[i] = -c[i]; } for (int i = 0; i < n; i++){ dist[i] = INF; } dist[0] = 0; for (int i = 0; i <= n; i++){ for (int j = 0; j < m; j++){ if (dist[b[j]] > dist[a[j]] + c[j]){ dist[b[j]] = dist[a[j]] + c[j]; if (i == n){ cout << "inf" << endl; return 0; } } } } cout << -dist[n-1] << endl; }
a.cc:10:1: error: expected initializer before 'll' 10 | ll dist[2000]; | ^~ a.cc: In function 'int main()': a.cc:15:32: error: 'c' was not declared in this scope 15 | cin >> a[i] >> b[i] >> c[i]; | ^ a.cc:21:9: error: 'dist' was not declared in this scope 21 | dist[i] = INF; | ^~~~ a.cc:23:5: error: 'dist' was not declared in this scope 23 | dist[0] = 0; | ^~~~ a.cc:27:43: error: 'c' was not declared in this scope 27 | if (dist[b[j]] > dist[a[j]] + c[j]){ | ^
s986917677
p03722
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #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=(b)-1; i>=(a); --i) #define DEBUG(x) cout<<#x<<": "<<x<<'\n' #define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n' #define ALL(a) (a).begin(), (a).end() #define CHMIN(a, b) a=min((a), (b)) #define CHMAX(a, b) a=max((a), (b)) const ll MOD=1000000007ll; // const ll MOD=998244353ll; #define FIX(a) ((a)%MOD+MOD)%MOD const double EPS=1e-11; #define EQ0(x) (abs((x))<EPS) #define EQ(a, b) (abs((a)-(b))<EPS) const ll INF=1e18; const int MAX_E=2525; const int MAX_V=1252; struct edge { int from; int to; ll cost; }; // 辺 edge es[MAX_E]; // 最短距離 ll d[MAX_V]; int V, E; void shortest_path(int s){ fill(d, d+V, INF); d[s]=0; while(true){ bool update=false; REP(i, E){ edge e=es[i]; if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){ d[e.to]=d[e.from]+e.cost; update=true; } } if(!update){ break; } } } // 負の閉路があるか判定 bool find_negative_loop(){ memset(d, 0, sizeof(d)); REP(i, V){ REP(j, E){ edge e=es[j]; if(d[e.to]>d[e.from]+e.cost){ d[e.to]=d[e.from]+e.cost; if(i==V-1){ return true; } } } } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m, a, b ll c; cin>>n>>m; V=n; E=m; REP(i, m){ edge e; cin>>a>>b>>c; e.from=a-1; e.to=b-1; e.cost=-c; es[i]=e; } if(find_negative_loop()){ cout<<"inf"<<'\n'; } else{ shortest_path(0); cout<<-d[n-1]<<'\n'; } return 0; }
a.cc: In function 'int main()': a.cc:87:9: error: expected initializer before 'll' 87 | ll c; | ^~ a.cc:93:25: error: 'b' was not declared in this scope 93 | cin>>a>>b>>c; | ^ a.cc:93:28: error: 'c' was not declared in this scope 93 | cin>>a>>b>>c; | ^
s639468919
p03722
C++
#include <iostream> #include <algorithm> #include <cmath> #include <limits> #include <vector> #include <cstdio> #include <bits/stdc++.h> #include <set> #include <map> #include <stdio.h> #include <stack> #include <queue> #include <deque> #include <numeric> #define MAX 100000007 using namespace std; using ll = long long; map <int ,int> mpa,mpb; typedef pair<ll, ll> P; priority_queue<P, vector<P>, greater<P>> pque; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); int N,M; cin >> N >> M; int a[M],b[M]; ll c[M]; ll ans=0; ll dp[1001]; for(int i=0;i<M;i++){ cin >> a[i] >> b[i] >> c[i]; c[i]=-c[i]; a[i]=a[i]-1; b[i]=b[i]-1; } for(int i=0;i<N;i++){ dist[i]=MAX; } dist[0]=0; for(int loop=0;loop<N-1;loop++){ for(int i=0;i<M;i++){ if(a[i]==INF) continue; if(dist[b[i]] > dist[a[i]]+c[i]){ dist[b[i]]=dist[a[i]]+c[i]; } } } ans =dist[N-1]; }
a.cc: In function 'int main()': a.cc:38:5: error: 'dist' was not declared in this scope 38 | dist[i]=MAX; | ^~~~ a.cc:40:3: error: 'dist' was not declared in this scope 40 | dist[0]=0; | ^~~~ a.cc:43:16: error: 'INF' was not declared in this scope 43 | if(a[i]==INF) continue; | ^~~
s703814392
p03722
C++
include<cstdio> int main(){ printf("inf\n"); }
a.cc:1:1: error: 'include' does not name a type 1 | include<cstdio> | ^~~~~~~
s255848696
p03722
C++
int main(){ printf("inf\n"); }
a.cc: In function 'int main()': a.cc:2:1: error: 'printf' was not declared in this scope 2 | printf("inf\n"); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int main(){
s349638007
p03722
C++
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <queue> #include <string> #include <set> #include <map> #define REP(i,n) for(ll i = 0; i < (ll)n; i++) #define INF 10000000000000000 using namespace std; typedef long long ll; typedef double db; typedef string str; struct edge{ll from, to, cost;}; struct graph{ ll V; vector<ll> d; vector<edge> es; graph(ll n){ init(n); } void init(ll n){ V = n; d.resize(V); REP(i,V){ d[i] = INF; } } void add_edge(ll from, ll to, ll cost){ edge e; e.from = from, e.to = to, e.cost = cost; es.push_back(e); } void bellman_ford(ll s){ REP(i,V) d[i] = INF; d[s] = 0; REP(i,V-1){ bool update = false; for(auto e:es){ if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){ d[e.to] = d[e.from] + e.cost; update = true; } } if(!update) break; } } bool negative_loop(ll gl){ REP(i,V) d[i] = 0; REP(i,V){ for(auto e:es){ if(d[e.to]>d[e.from]+e.cost){ d[e.to] = d[e.from]+e.cost; if(i==V-1&&e.to==gl) return true; } } } return false; } }; int main(){ ll n,m; cin >> n >> m; graph g(n); REP(i,m){ ll a, b,c; cin >> a >> b >> c; g.add_edge(a-1,b-1,-c); } if(g.negative_loop()){ cout << "inf" << endl; }else{ g.bellman_ford(0); cout << -g.d[n-1] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:74:21: error: no matching function for call to 'graph::negative_loop()' 74 | if(g.negative_loop()){ | ~~~~~~~~~~~~~~~^~ a.cc:51:8: note: candidate: 'bool graph::negative_loop(ll)' 51 | bool negative_loop(ll gl){ | ^~~~~~~~~~~~~ a.cc:51:8: note: candidate expects 1 argument, 0 provided
s635027566
p03722
C++
#include "stdafx.h" #include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <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 <iomanip> using namespace std; #define INF 1e9 #define PI acos(-1) typedef long long ll; typedef pair<int, int> p_ii; int main() { bool check = false; int n, m, i, j, k; cin >> n >> m; vector<ll> score(n, -INF*INF); vector<vector<ll>> G(n, vector<ll>(n, -INF*INF)); for (i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; cin >> G[a][b]; } score[0] = 0; for (i = 0; i < n; i++) { bool update = false; for (j = 0; j < n; j++) { for (k = 0; k < n; k++) { if (j!=k && G[j][k] != -INF * INF && score[j] != -INF * INF && score[k] < score[j] + G[j][k]) { score[k] = score[j] + G[j][k]; update = true; } } } if (!update)break; if (i == n - 1)check = true; } if (check)cout << "inf" << endl; else cout << score[n - 1] << endl; return 0; }
a.cc:1:10: fatal error: stdafx.h: No such file or directory 1 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s512236774
p03722
C++
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <limits> using namespace std; #define REP(i,a,b) for(int i=a;i<b;i++) #define rep(i,n) REP(i,0,n) using Weight = int64_t; struct Edge { int src, dst; Weight weight; }; constexpr int64_t INF = 1LL<<59; using Edges = vector<Edge>; using Graph = vector<Edges>; bool shortestPath(const Graph g, int s, vector<Weight> &dist) { int n = g.size(); dist.assign(n, INF); dist[s] = 0; bool negative_cycle = false; rep(k, n) rep(i, n) for(auto e: g[i]) { if (dist[e.dst] > dist[e.src] + e.weight) { dist[e.dst] = dist[e.src] + e.weight; if (k == n-1) { dist[e.dst] = -INF; negative_cycle = true; } } } return !negative_cycle; } int main() { int N, M; cin >> N >> M; Graph G(N); rep(i, M) { Edge e; cin >> e.src >> e.dst >> e.weight; e.src--, e.dst--, e.weight *= -1; G[e.src].push_back(Edge{e.src, e.dst, e.weight}); } vector<Weight> w; shortestPath(G, 0, w); if (dist[N - 1] > -INF) { cout << -w[N - 1] << "\n"; } else { cout << "inf\n"; } }
a.cc: In function 'int main()': a.cc:50:13: error: 'dist' was not declared in this scope 50 | if (dist[N - 1] > -INF) { | ^~~~
s995511799
p03722
C++
#include <iostream> #include <algorithm> #include <cmath> #include <vector> using namespace std; #define REP(i,a,b) for(int i=a;i<b;i++) #define rep(i,n) REP(i,0,n) using Weight = int64_t; struct Edge { int src, dst; Weight weight; }; using Edges = vector<Edge>; using Graph = vector<Edges>; bool shortestPath(const Graph g, int s, vector<Weight> &dist, vector<int> &prev) { int n = g.size(); dist.assign(n, INF+INF); dist[s] = 0; prev.assign(n, -2); bool negative_cycle = false; rep(k, n) rep(i, n) for(auto e: g[i]) { if (dist[e.dst] > dist[e.src] + e.weight) { dist[e.dst] = dist[e.src] + e.weight; prev[e.dst] = e.src; if (k == n-1) { dist[e.dst] = std::numeric_limits<int64_t>::min(); negative_cycle = true; } } } return !negative_cycle; } int main() { int N, M; cin >> N >> M; Graph G(N); rep(i, M) { Edge e; cin >> e.src >> e.dst >> e.weight; e.src--, e.dst--, e.weight *= -1; G[e.src].push_back(Edge{e.src, e.dst, e.weight}); } vector<Weight> w; vector<int> prev; if (shortestPath(G, 0, w, prev)) { cout << -w[N - 1] << "\n"; } else { cout << "inf\n"; } }
a.cc: In function 'bool shortestPath(Graph, int, std::vector<long int>&, std::vector<int>&)': a.cc:23:18: error: 'INF' was not declared in this scope 23 | dist.assign(n, INF+INF); dist[s] = 0; | ^~~
s268034177
p03722
C++
#include <iostream> #include <algorithm> #include <queue> #include <string> #include <map> #include <math.h> #include <set> using namespace std; typedef long long ll; #define rep(i,s,n)for(ll i=s;i<n;i++) #define repe(i,s,n)for(ll i=s;i<=n;i++) static const double PI = 3.1415926535897932384626433; static const ll INF = (ll)1 << 55; /////////////////////////// ////Prime Creator////////// /////////////////////////// //bool Prime[100001] = {}; //void createPrime() { // ll n = 100001; // rep(i, 0, n) Prime[i] = true; // Prime[0] = false; // Prime[1] = false; // rep(i, 2, n) { // if (Prime[i]) { // rep(j, 2, n) { // if (j*i >= n)break; // Prime[j*i] = false; // } // } // } //} /////////////////////////// /////////////////////////// ///////////////////////// //Warshal Floyid///////// ///////////////////////// //initialize` //rep(i, 0, N)rep(j, 0, N) wf[i][j] = 1 << 29; //static const ll WF_MAX = 300; //ll wf[WF_MAX][WF_MAX]; //void WarshalFloyid(int size) { // rep(k, 0, size)rep(i, 0, size)rep(j, 0, size)wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]); //} //////////// ///dijkstra /////////// //ll N; //static const ll MAX = 100001; //static const ll INFTY = (ll)1 << 55; //static const int WHITE = 1; //static const int GRAY = 2; //static const int BLACK = 3; //vector<pair<int, int>>adj[MAX]; //ll d[MAX]; //ll pre[MAX]; // //priority_queue<pair<int, int>>PQ; //int color[MAX]; //ll n; //void dijkstra(ll x) { // repe(i, 1, n) { // d[i] = INFTY; // color[i] = WHITE; // } // // d[x] = 0; // PQ.push(make_pair(x, x)); // color[x] = GRAY; // while (!PQ.empty()) { // pair<ll, ll> f = PQ.top(); PQ.pop(); // ll u = f.second; // color[u] = BLACK; // // if (d[u] < f.first * (-1))continue; // // rep(j, 0, adj[u].size()) { // ll v = adj[u][j].first; // if (color[v] == BLACK)continue; // if (d[v] > d[u] + adj[u][j].second) { // d[v] = d[u] + adj[u][j].second; // pre[v] = u; // PQ.push(make_pair(d[v] * (-1), v)); // // color[v] = GRAY; // } // } // } //} //vector<ll> get_path(ll t) { // vector<ll> path; // for (; t != -1; t = pre[t])path.push_back(t); // reverse(path.begin(), path.end()); // return path; //} //Belmonford // 隣接リストで使う辺を表す型 struct Edge { ll to, cost; // 辺の接続先頂点, 辺の重み Edge(int to, int cost) : to(to), cost(cost) {} // コンストラクタ }; typedef vector<vector<Edge>> AdjList; // 隣接リストの型 AdjList graph; // グラフの辺を格納した構造体 // graph[v][i]は頂点vから出るi番目の辺Edge vector<ll> dist; // 最短距離 // 戻り値がtrueなら負の閉路を含む bool bellman_ford(ll n, ll s) { // nは頂点数、sは開始頂点 dist = vector<ll>(n, INF); dist[s] = 0; // 開始点の距離は0 for (int i = 0; i < n; i++) { for (int v = 0; v < n; v++) { for (int k = 0; k < graph[v].size(); k++) { Edge e = graph[v][k]; if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) { dist[e.to] = dist[v] + e.cost; // cout << "update" << endl; if (i == n - 1) { cout << "inf" << endl; return true; //return true; // n回目にも更新があるなら負の閉路が存在 } } } } } return false; } int main() { int n, m, r; cin >> n >> m; ll a[2000] = {}; ll b[2000] = {}; ll c[2000] = {}; graph = AdjList(n); rep(i, 0, m) { ll from, to, cost; cin >> from >> to >> cost; a[i] = from - 1; b[i] = to - 1; c[i] = -cost; graph[from - 1].push_back(Edge(to - 1, -cost)); } if (!bellman_ford(n, 0)) { cout << -dist[n - 1] << endl; return 0; } else { return; } bool negative[2000]; rep(i, 0, n) negative[i] = false; rep(l, 0, n) { rep(i, 0, n) { if (dist[a[i]] == INF)continue; if (dist[b[i]] > dist[a[i]] + c[i]) { dist[b[i]] = dist[a[i]] + c[i]; negative[b[i]] = true; } if (negative[a[i]]) { negative[b[i]] = true; } } } if (negative[n - 1]) { cout << "inf" << endl; } else { cout << -dist[n - 1] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:162:17: error: return-statement with no value, in function returning 'int' [-fpermissive] 162 | return; | ^~~~~~
s510002259
p03722
C++
#include <iostream> #include <string> #include <queue> #include <vector> #include <set> #include <map> #include <algorithm> #include <utility> #define ll long long int #define pb push_back #define mk make_pair #define pq priority_queue using namespace std; typedef pair<int, int> P; typedef pair<ll, int> Pl; const int inf = 1e9; const ll linf = 1LL << 50; int n, m; typedef struct edge_ { int from, to, cost; edge_(int f, int t, int c): from(f), to(t), cost(c){}; } edge; vector<edge> vec; ll d[1001]; bool bellmanford(){ bool updated; fill(d, d+n, linf); d[0] = 0; for(int i = 0; i <= n; i++){ updated = false; for(auto itr = vec.begin(); itr != vec.end(); ++itr){ int from = (*itr).from; int to = (*itr).to; int cost = (*itr).cost; if(d[from] != linf && d[from] + (ll)cost < d[to]){ if(e.to == n - 1)updated = true; d[to] = d[from] + (ll)cost; } } } return !updated; } int main(int argc, char const* argv[]) { cin >> n >> m; for(int i = 0; i < m; i++){ int a, b, c; cin >> a >> b >> c; a--; b--; vec.pb(edge(a, b, -c)); } if(bellmanford())cout << -d[n - 1] << endl; else cout << "inf" << endl; return 0; }
a.cc: In function 'bool bellmanford()': a.cc:42:68: error: 'e' was not declared in this scope 42 | if(e.to == n - 1)updated = true; | ^
s417856404
p03722
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll MAX = 1e+15; typedef struct{ ll s; ll t; ll c; } edge; ll n,m; vector<vector<edge>> g,ig,subg; ll longest_path() { vector<int> indeg(n,0); for(auto es : subg) { for(auto e : es) { indeg[e.t]++; } } stack<int> L; L.push(0); vector<ll> ans(n,0); while(1) { if( L.size() == 0 ) break; int v = L.top(); L.pop(); for(auto e : subg[v]) { indeg[e.t]--; if( indeg[e.t] == 0 ) L.push(e.t); ans[e.t] = max(ans[e.t],ans[v] + e.c); } } if( indeg[n-1] == 0 ) return ans[n-1]; else return MAX; } void dfs(int n,vector<vector<edge>>& graph, vector<int>& is_traverced, set<edge> res ){ is_traverced[n] = 1; for(auto e : graph[n]) { res.insert(e); if( is_traverced[e.t] == 1 ) continue; dfs(e.t, graph, is_traverced, res); } } set<edge> traverce(int n, vector<vector<edge>>& graph ) { set<edge> res; vector<int> is_traverced(n,0); dfs(n,graph,is_traverced,res); return res; } void make_subg(){ set<edge> sn = traverce(0,g); set<edge> tn = traverce(n-1,ig); for(auto e : sn) if( tn.count({e.t, e.s, e.c}) != 0 ) subg[e.s].push_back(e); return; } void solve(){ // 1-Nパスに含まれる頂点からなる部分グラフ make_subg(); // 上記グラフがDAGか否か ll ans = longest_path(); if(ans == MAX) cout << "inf" << endl; else cout << ans << endl; } int main() { cin >> n >> m; g = vector<vector<edge>>(n); ig= vector<vector<edge>>(n); for(int i=0; i<n; i++) { ll a,b,c; cin >> a >> b >> c; a--;b--; g[a].push_back({a,b,c}); ig[b].push_back({b,a,c}); } solve(); }
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:1: /usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = edge]': /usr/include/c++/14/bits/stl_tree.h:2545:33: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = edge; _Val = edge; _KeyOfValue = std::_Identity<edge>; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; const_iterator = std::_Rb_tree<edge, edge, std::_Identity<edge>, std::less<edge>, std::allocator<edge> >::const_iterator]' 2545 | || _M_impl._M_key_compare(__k, | ~~~~~~~~~~~~~~~~~~~~~~^~~~~ 2546 | _S_key(__j._M_node))) ? end() : __j; | ~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_set.h:751:25: required from 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = edge; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; size_type = long unsigned int; key_type = edge]' 751 | { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } | ~~~~~~~~~^~~~~ a.cc:65:16: required from here 65 | if( tn.count({e.t, e.s, e.c}) != 0 ) | ~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const edge' and 'const edge') 405 | { return __x < __y; } | ~~~~^~~~~ 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 edge' 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 edge' 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 edge' 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 edge' 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 edge' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~
s056767410
p03722
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll MAX = 1e+15; typedef struct{ ll s; ll t; ll c; } edge; ll n,m; vector<vector<edge>> g,ig,subg; ll longest_path() { vector<int> indeg(n,0); for(auto es : subg) { for(auto e : es) { indeg[e.t]++; } } stack<int> L; L.push(0); vector<ll> ans(n,0); while(1) { if( L.size() == 0 ) break; int v = L.top(); L.pop(); for(auto e : subg[v]) { indeg[e.t]--; if( indeg[e.t] == 0 ) L.push(e.t); ans[e.t] = max(ans[e.t],ans[v] + e.c); } } if( indeg[n-1] == 0 ) return ans[n-1]; else return MAX; } void dfs(int n,vector<vector<edge>>& graph, vector<int>& is_traverced, set<edge> res ){ is_traverced[n] = 1; for(auto e : graph[n]) { res.insert(e); if( is_traverced[e.t] == 1 ) continue; dfs(e.t, graph, is_traverced, res); } } set<edge> traverce(int n, vector<vector<edge>>& graph ) { set<edge> res; vector<int> is_traverced(n,0); dfs(n,graph,is_traverced,res); return res; } void make_subg(){ set<edge> sn = traverce(0,g); set<edge> tn = traverce(n-1,ig); for(auto e : sn) if( tn.count({e.t, e.s, e.c}) != 0 ) subg[e.s].push_back(e); return; } void solve(){ // 1-Nパスに含まれる頂点からなる部分グラフ make_subg(); // 上記グラフがDAGか否か ll ans = longest_path(); if(ans == MAX) cout << "inf" << endl; else cout << ans <, endl; } int main() { cin >> n >> m; g = vector<vector<edge>>(n); ig= vector<vector<edge>>(n); for(int i=0; i<n; i++) { ll a,b,c; cin >> a >> b >> c; a--;b--; g[a].push_back({a,b,c}); ig[b].push_back({b,a,c}); } solve(); }
a.cc: In function 'void solve()': a.cc:80:18: error: expected primary-expression before ',' token 80 | cout << ans <, endl; | ^ 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:1: /usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = edge]': /usr/include/c++/14/bits/stl_tree.h:2545:33: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = edge; _Val = edge; _KeyOfValue = std::_Identity<edge>; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; const_iterator = std::_Rb_tree<edge, edge, std::_Identity<edge>, std::less<edge>, std::allocator<edge> >::const_iterator]' 2545 | || _M_impl._M_key_compare(__k, | ~~~~~~~~~~~~~~~~~~~~~~^~~~~ 2546 | _S_key(__j._M_node))) ? end() : __j; | ~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_set.h:751:25: required from 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = edge; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; size_type = long unsigned int; key_type = edge]' 751 | { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } | ~~~~~~~~~^~~~~ a.cc:65:16: required from here 65 | if( tn.count({e.t, e.s, e.c}) != 0 ) | ~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const edge' and 'const edge') 405 | { return __x < __y; } | ~~~~^~~~~ 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 edge' 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 edge' 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 edge' 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 edge' 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 edge' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~
s274600648
p03722
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll MAX = 1e+15; typedef struct{ ll s; ll t; ll c; } edge; ll n,m; vector<vector<edge>> g,ig,subg; ll longest_path() { vector<int> indeg(n,0); for(auto es : subg) { for(auto e : es) { indeg[e.t]++; } } stack<int> L; L.push(0); vector<ll> ans(n,0); while(1) { if( L.size() == 0 ) break; int v = L.top(); L.pop(); for(auto e : sung[v]) { indeg[e.t]--; if( indeg[e.t] == 0 ) L.push(e.t); ans[e.t] = max(ans[e.t],ans[v] + e.c); } } if( indeg[n-1] == 0 ) return ans[n-1]; else return MAX; } void dfs(int n,vector<vector<edge>>& graph, vector<int>& is_traverced, set<edge> res ){ is_traverced[n] = 1; for(auto e : graph[n]) { res.insert(e); if( is_traverced[e.t] == 1 ) continue; dfs(e.t, graph, is_traverced, res); } } set<edge> traverce(int n, vector<vector<edge>>& graph ) { set<edge> res; vector<int> is_traverced(n,0); dfs(n,graph,is_traverced,res); return res; } void make_subg(){ set<edge> sn = traverse(0,g); set<edge> tn = traverse(n-1,ig); for(auto e : sn) if( tn.count({e.t, e.s, e.c} != 0 ) subg[e.s].push_back(e); return; } ll solve(){ // 1-Nパスに含まれる頂点からなる部分グラフ make_subg(); // 上記グラフがDAGか否か return longest_path(); } int main() { cin >> n >> m; g = vector<vector<edge>>(n); ig= vector<vector<edge>>(n); for(int i=0; i<n; i++) { ll a,b,c; cin >> a >> b >> c; a--;b--; g[a].push_back({a,b,c}); ig[b].push_back({b,a,c}); } cout << (solve()==MAX ? "inf" : solve()) << endl; }
a.cc: In function 'll longest_path()': a.cc:27:18: error: 'sung' was not declared in this scope; did you mean 'subg'? 27 | for(auto e : sung[v]) { | ^~~~ | subg a.cc: In function 'void make_subg()': a.cc:61:18: error: 'traverse' was not declared in this scope; did you mean 'traverce'? 61 | set<edge> sn = traverse(0,g); | ^~~~~~~~ | traverce a.cc:65:37: error: expected ')' before '!=' token 65 | if( tn.count({e.t, e.s, e.c} != 0 ) | ~ ^~~ | ) a.cc:65:44: error: expected ';' before 'subg' 65 | if( tn.count({e.t, e.s, e.c} != 0 ) | ^ | ; 66 | subg[e.s].push_back(e); | ~~~~ a.cc:68:3: error: expected primary-expression before 'return' 68 | return; | ^~~~~~ a.cc:66:31: error: expected ')' before 'return' 66 | subg[e.s].push_back(e); | ^ | ) 67 | 68 | return; | ~~~~~~ a.cc:65:11: note: to match this '(' 65 | if( tn.count({e.t, e.s, e.c} != 0 ) | ^ a.cc: In function 'int main()': a.cc:91:25: error: operands to '?:' have different types 'const char*' and 'll' {aka 'long long int'} 91 | cout << (solve()==MAX ? "inf" : solve()) << endl; | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 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:1: /usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = edge]': /usr/include/c++/14/bits/stl_tree.h:2545:33: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = edge; _Val = edge; _KeyOfValue = std::_Identity<edge>; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; const_iterator = std::_Rb_tree<edge, edge, std::_Identity<edge>, std::less<edge>, std::allocator<edge> >::const_iterator]' 2545 | || _M_impl._M_key_compare(__k, | ~~~~~~~~~~~~~~~~~~~~~~^~~~~ 2546 | _S_key(__j._M_node))) ? end() : __j; | ~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_set.h:751:25: required from 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = edge; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; size_type = long unsigned int; key_type = edge]' 751 | { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } | ~~~~~~~~~^~~~~ a.cc:65:16: required from here 65 | if( tn.count({e.t, e.s, e.c} != 0 ) | ~~~~~~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const edge' and 'const edge') 405 | { return __x < __y; } | ~~~~^~~~~ 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 edge' 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 edge' 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 edge' 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 edge' 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 edge' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~
s742025628
p03722
Java
import java.util.*; public class Main { static int modP = 1000000007; static long inf = Long.MAX_VALUE; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); List<E> edges = new ArrayList<>(); for(int i = 0; i < m; i++) { int a = in.nextInt()-1; int b = in.nextInt()-1; long c = -in.nextInt(); E e = new E(a, b, c); edges.add(e); } long[] dist = new long[n]; Arrays.fill(dist, inf); dist[0] = 0; int loopCnt = 0; boolean infCond = false; while(true) { if(loopCnt > 2*n) { infCond = true; break; } loopCnt++; boolean updated = false; for(E e : edges) { if(dist[e.from] != inf && dist[e.from] + e.w < dist[e.to]) { dist[e.to] = dist[e.from] + e.w; updated = true; } } if(!updated) break; } if(infCond) { print("inf"); }else{ print(-dist[n-1]); } } static void print(String s) { System.out.println(s); } static void print(int i) { System.out.println(i); } static void print(long i) { System.out.println(i); } }
Main.java:10: error: cannot find symbol List<E> edges = new ArrayList<>(); ^ symbol: class E location: class Main Main.java:15: error: cannot find symbol E e = new E(a, b, c); ^ symbol: class E location: class Main Main.java:15: error: cannot find symbol E e = new E(a, b, c); ^ symbol: class E location: class Main Main.java:32: error: cannot find symbol for(E e : edges) { ^ symbol: class E location: class Main 4 errors
s455899109
p03722
C++
#include <bits/stdc++.h> using namespace std; typedef lon glong ll; ll MAX = 1e+15; typedef struct{ ll t; ll c; } edge; ll n,m; vector<vector<edge>> g,subg; ll longest_path() { vector<int> indeg(n,0); for(auto es : subg) { for(auto e : es) { indeg[e.t]++; } } while(1) { int v = -1; for(int i=0;i<n;i++) if( indeg[i] == -1 ) v = i; } } ll solve(){ // 1-Nパスに含まれる頂点からなる部分グラフ // 上記グラフがDAGか否か // --> DAGならば、最長路計算 // --> else return inf if( is_dag() ) return longest_path(); else return MAX; } int main() { cin >> n >> m; g = vector<vector<edge>>(n); for(int i=0; i<n; i++) { ll a,b,c; cin >> a >> b >> c; a--;b--; g[a].push_back({b,c}); g[b].push_back({a,c}); } cout << (solve()==MAX ? "inf" : solve()) << endl; }
a.cc:3:9: error: 'lon' does not name a type; did you mean 'long'? 3 | typedef lon glong ll; | ^~~ | long a.cc:4:1: error: 'll' does not name a type 4 | ll MAX = 1e+15; | ^~ a.cc:6:3: error: 'll' does not name a type 6 | ll t; | ^~ a.cc:7:3: error: 'll' does not name a type 7 | ll c; | ^~ a.cc:10:1: error: 'll' does not name a type 10 | ll n,m; | ^~ a.cc:13:1: error: 'll' does not name a type 13 | ll longest_path() { | ^~ a.cc:34:1: error: 'll' does not name a type 34 | ll solve(){ | ^~ a.cc: In function 'int main()': a.cc:49:10: error: 'n' was not declared in this scope; did you mean 'yn'? 49 | cin >> n >> m; | ^ | yn a.cc:49:15: error: 'm' was not declared in this scope; did you mean 'tm'? 49 | cin >> n >> m; | ^ | tm a.cc:52:5: error: 'll' was not declared in this scope 52 | ll a,b,c; cin >> a >> b >> c; | ^~ a.cc:52:22: error: 'a' was not declared in this scope 52 | ll a,b,c; cin >> a >> b >> c; | ^ a.cc:52:27: error: 'b' was not declared in this scope 52 | ll a,b,c; cin >> a >> b >> c; | ^ a.cc:52:32: error: 'c' was not declared in this scope 52 | ll a,b,c; cin >> a >> b >> c; | ^ a.cc:58:12: error: 'solve' was not declared in this scope 58 | cout << (solve()==MAX ? "inf" : solve()) << endl; | ^~~~~ a.cc:58:21: error: 'MAX' was not declared in this scope 58 | cout << (solve()==MAX ? "inf" : solve()) << endl; | ^~~
s002948700
p03722
C++
#include <bits/stdc++.h> using namespace std; typedef lon glong ll; typedef struct{ ll t; ll c; } edge; ll n,m; vector<edge> g; int main() { cin >> n >> m; g = vector<edge>(n); for(int i=0; i<n; i++) { ll a,b,c; cin >> a >> b >> c; a--;b--; g[a].push_back({b,c}); g[b].push_back({a,c}); } }
a.cc:3:9: error: 'lon' does not name a type; did you mean 'long'? 3 | typedef lon glong ll; | ^~~ | long a.cc:6:3: error: 'll' does not name a type 6 | ll t; | ^~ a.cc:7:3: error: 'll' does not name a type 7 | ll c; | ^~ a.cc:10:1: error: 'll' does not name a type 10 | ll n,m; | ^~ a.cc: In function 'int main()': a.cc:15:10: error: 'n' was not declared in this scope; did you mean 'yn'? 15 | cin >> n >> m; | ^ | yn a.cc:15:15: error: 'm' was not declared in this scope; did you mean 'tm'? 15 | cin >> n >> m; | ^ | tm a.cc:18:5: error: 'll' was not declared in this scope 18 | ll a,b,c; cin >> a >> b >> c; | ^~ a.cc:18:22: error: 'a' was not declared in this scope 18 | ll a,b,c; cin >> a >> b >> c; | ^ a.cc:18:27: error: 'b' was not declared in this scope 18 | ll a,b,c; cin >> a >> b >> c; | ^ a.cc:18:32: error: 'c' was not declared in this scope 18 | ll a,b,c; cin >> a >> b >> c; | ^
s278305934
p03722
C++
#include <bits/stdc++.h> using namespace std; #define NDEBUG #ifdef DEBUG #include "../cout11.h" #undef NDEBUG #endif #include <cassert> typedef long long ll; typedef long double Double; typedef unsigned long long ull; typedef pair<int,int> ii; typedef pair<ll,ll> llll; typedef pair<double,double> dd; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<ii> vii; typedef vector<vector<ii>> vvii; typedef vector<ll> vll; typedef vector<string> vs; typedef vector<double> vd; typedef vector<long double> vD; #define sz(a) int((a).size()) #define pb push_back #define FOR(var,from,to) for(int var=(from);var<=(to);++var) #define rep(var,n) for(int var=0;var<(n);++var) #define rep1(var,n) for(int var=1;var<=(n);++var) #define repC2(vari,varj,n) for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj) #define ALL(c) (c).begin(),(c).end() #define RALL(c) (c).rbegin(),(c).rend() #define tr(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i) #define found(s,e) ((s).find(e)!=(s).end()) #define mset(arr,val) memset(arr,val,sizeof(arr)) #define mid(x,y) ((x)+((y)-(x))/2) #define IN(x,a,b) ((a)<=(x)&&(x)<=(b)) #define cons make_pair #define NEG_INFTY 0x8000000000000000LL typedef pair<ll,int> Li; void solve(int N,int M,vi& a,vi& b,vi& c) { vector<vector<ii>> next(N); rep(i,M){ int x=a[i],y=b[i],z=c[i]; next[x].pb(ii(y,z)); } #ifdef DEBUG // rep(i,N){ // cerr << "next[" << i << "] -> " << next[i] << endl; // } #endif vector<ll> dist(N, NEG_INFTY); vector<int> prev(N, -1); queue<pair<ll,ii>> q; // distance, (from, to) q.push( make_pair(0LL,ii(-1,0)) ); while (!q.empty()){ auto t = q.front(); q.pop(); #ifdef DEBUG cerr << ": " << t << endl; #endif ll d = t.first; int from = t.second.first, here = t.second.second; if (prev[here] == -2) { dist[here] = d; prev[here] = from; } else { if (prev[here] == from && d > 0) { cout << "inf" <<s endl; return; } if (d > dist[here]) { dist[here] = d; prev[here] = from; } else { continue; } } for (ii nx : next[here]) { if (prev[nx.first] == -1 || dist[nx.first] < d + nx.second) { q.push( make_pair(d + nx.second, ii(here, nx.first)) ); } } } #ifdef DEBUG cerr << dist << endl; cerr << prev << endl; #endif cout << dist[N-1] << endl; } int main() { int N,M;cin>>N>>M; vi a(M),b(M),c(M); rep(i,M){ cin>>a[i]>>b[i]>>c[i]; --a[i]; --b[i]; } solve(N,M,a,b,c); return 0; }
a.cc: In function 'void solve(int, int, vi&, vi&, vi&)': a.cc:75:33: error: 's' was not declared in this scope 75 | cout << "inf" <<s endl; | ^
s677624276
p03722
C++
#include <bits/stdc++.h> using namespace std; #define NDEBUG #ifdef DEBUG #include "../cout11.h" #undef NDEBUG #endif #include <cassert> typedef long long ll; typedef long double Double; typedef unsigned long long ull; typedef pair<int,int> ii; typedef pair<ll,ll> llll; typedef pair<double,double> dd; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<ii> vii; typedef vector<vector<ii>> vvii; typedef vector<ll> vll; typedef vector<string> vs; typedef vector<double> vd; typedef vector<long double> vD; #define sz(a) int((a).size()) #define pb push_back #define FOR(var,from,to) for(int var=(from);var<=(to);++var) #define rep(var,n) for(int var=0;var<(n);++var) #define rep1(var,n) for(int var=1;var<=(n);++var) #define repC2(vari,varj,n) for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj) #define ALL(c) (c).begin(),(c).end() #define RALL(c) (c).rbegin(),(c).rend() #define tr(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i) #define found(s,e) ((s).find(e)!=(s).end()) #define mset(arr,val) memset(arr,val,sizeof(arr)) #define mid(x,y) ((x)+((y)-(x))/2) #define IN(x,a,b) ((a)<=(x)&&(x)<=(b)) #define cons make_pair #define NEG_INFTY 0x8000000000000000LL typedef pair<ll,int> Li; void solve(int N,int M,vi& a,vi& b,vi& c) { vector<vector<ii>> next(N); rep(i,M){ int x=a[i],y=b[i],z=c[i]; next[x].pb(ii(y,z)); } #ifdef DEBUG // rep(i,N){ // cerr << "next[" << i << "] -> " << next[i] << endl; // } #endif vector<ll> dist(N, NEG_INFTY); vector<int> prev(N, -1); queue<pair<ll,ii>> q; // distance, (from, to) q.push( make_pair(0LL,ii(-1,0)) );s while (!q.empty()){ auto t = q.front(); q.pop(); #ifdef DEBUG cerr << ": " << t << endl; #endif ll d = t.first; int from = t.second.first, here = t.second.second; if (prev[here] == -2) { dist[here] = d; prev[here] = from; } else { if (prev[here] == from && d > 0) { cout << "inf" <<s endl; return; } if (d > dist[here]) { dist[here] = d; prev[here] = from; } else { continue; } } for (ii nx : next[here]) { if (prev[nx.first] == -1 || dist[nx.first] < d + nx.second) { q.push( make_pair(d + nx.second, ii(here, nx.first)) ); } } } #ifdef DEBUG cerr << dist << endl; cerr << prev << endl; #endif cout << dist[N-1] << endl; } int main() { int N,M;cin>>N>>M; vi a(M),b(M),c(M); rep(i,M){ cin>>a[i]>>b[i]>>c[i]; --a[i]; --b[i]; } solve(N,M,a,b,c); return 0; }
a.cc: In function 'void solve(int, int, vi&, vi&, vi&)': a.cc:62:39: error: 's' was not declared in this scope 62 | q.push( make_pair(0LL,ii(-1,0)) );s | ^
s932415219
p03722
C++
#include <iostream> #include <vector> #include <utility> using namespace std; using llong = long long; int main(){ int n,m; cin >> n >> m; vector<vector<pair<int,llong>>> graph(n); for(int i=0;i<m;++i){ int a,b; llong c; cin >> a >> b >> c; graph[a-1].emplace_back(b-1,-c); } llong INF = 100000000000000000; vector<llong> dist(n,INF); dist[0] = 0; for(int cnt=0;cnt<n;++cnt){ for(int i=0;i<n;++i){ for(const auto &p:graph[i]){ if(dist[p.first] > dist[i] + p.second){ dist[p.first] = dist[i] + p.second; if(cnt == n-1&&p.first = n-1){ cout << "inf" << endl; return 0; } } } } } cout << -dist[n-1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:27:24: error: lvalue required as left operand of assignment 27 | if(cnt == n-1&&p.first = n-1){ | ~~~~~~~~~~^~~~~~~~~
s733744042
p03722
C++
#include <iostream> using namespace std; int main(){ long long a,b,c; cin >> V >> E; int i,j; for(i=0;i<E;i++){ cin >> a >> b >> c ; } cout << "inf" << endl; }
a.cc: In function 'int main()': a.cc:7:16: error: 'V' was not declared in this scope 7 | cin >> V >> E; | ^ a.cc:7:21: error: 'E' was not declared in this scope 7 | cin >> V >> E; | ^
s898031284
p03722
C++
#include<cstdio> #include<cstring> #include<vector> #include<queue> #include<algorithm> #include<cmath> #include<climits> #include<string> #include<set> #include<numeric> #include<map> #include<iostream> using namespace std; #define rep(i,n) for(int i = 0;i<((int)(n));i++) #define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++) #define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--) #define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--) typedef long long ll; typedef pair<ll, ll> mp; //LLONG_MIN int main(void){ int N,M,x,y,z; vector<int> v[1010]; vector<int> c[1010]; scanf("%d%d",&N,&M); rep(i,M){ scanf("%d%d%d",&x,&y,&z); v[x].push_back(y); c[x].push_back(z); } ll s1[1010],s2[1010],t; reg(i,1,N)s2[i]=-(1e14+10); s2[1]=0; reg(cnt,1,3*N+2){ reg(i,1,N)s1[i]=s2[i]; reg(i,1,N){ rep(j,v[i].size()){ if(s2[v[i][j]]<s1[i]+c[i][j])s2[v[i][j]]=s1[i]+c[i][j]; } } if(i==N-1)t=s2[N]; } if(s2[N]>t){ printf("inf\n"); }else{ printf("%lld\n",s2[N]); } return 0; }
a.cc: In function 'int main()': a.cc:42:20: error: 'i' was not declared in this scope 42 | if(i==N-1)t=s2[N]; | ^
s011256595
p03722
C++
#include <iostream> #include <vector> #include<algorithm> #include<iomanip> #include<queue> #include<deque> #include<map> #include<bitset> #include<math.h> using namespace std; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define REP(i,m,n) for(ll i=m;i<(ll)(n);i++) typedef pair<int,long long> pint; typedef long long ll; const ll mod= 1e9+7; const ll longinf = 1LL<<60; int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1}; vector<pint> v[1010]; ll dist[1010]; int used[1010]; bool flag; void bfs(){ queue<int> q; q.push(0); dist[0]=0; while(q.size()){ int x=q.front();q.pop(); if(used[x]>=1010){ if(x==n-1){ flag=true; return; } continue; } for(auto e:v[x]){ if(dist[e.first]>dist[x]+e.second){ dist[e.first]=dist[x]+e.second; used[e.first]++; q.push(e.first); } } } } int main(){ int n,m; cin>>n>>m; rep(i,m){ ll a,b,c; cin>>a>>b>>c; v[a-1].push_back({b-1,-c}); } rep(i,n)dist[i]=longinf; bfs(); if(flag)cout<<"inf"<<endl; else cout<<-dist[n-1]<<endl; return 0; }
a.cc: In function 'void bfs()': a.cc:31:13: error: 'n' was not declared in this scope 31 | if(x==n-1){ | ^
s819174463
p03722
C++
n,m=io.read("*n","*n") d={} for i=1,n do d[i]={} for j=1,n do d[i][j]=(i==j and 0 or -1e15) end end for i=1,m do a,b,c=io.read("*n","*n","*n") d[a][b]=c end for k=1,n do for i=1,n do for j=1,n do d[i][j]=math.max(d[i][j],d[i][k]+d[k][j]) end end end print(d[1][1]>0 and"inf"or d[1][n])
a.cc:1:1: error: 'n' does not name a type 1 | n,m=io.read("*n","*n") | ^ a.cc:3:1: error: expected unqualified-id before 'for' 3 | for i=1,n do | ^~~ a.cc:5:9: error: expected unqualified-id before 'for' 5 | for j=1,n do | ^~~
s058243193
p03722
C++
#[allow(dead_code)] fn getline() -> String { let mut res = String::new(); std::io::stdin().read_line(&mut res).ok(); res } #[allow(unused_macros)] macro_rules! readl { ($t: ty) => { { let s = getline(); s.trim().parse::<$t>().unwrap() } }; ($( $t: ty),+ ) => { { let s = getline(); let mut iter = s.trim().split(' '); ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) } }; } #[allow(unused_macros)] macro_rules! readlvec { ($t: ty) => { { let s = getline(); let iter = s.trim().split(' '); iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>() } } } #[allow(unused_macros)] macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } } // macro_rules! debug { ($x: expr) => () } #[allow(dead_code)] fn show<T>(iter: T) -> String where T: Iterator, T::Item: std::fmt::Display { let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e)); res.pop(); res } #[allow(unused_imports)] use std::cmp::{max, min}; #[allow(unused_imports)] use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet}; #[allow(unused_imports)] use std::collections::btree_map::Entry::{Occupied, Vacant}; use std::cmp::Ordering; use std::clone::Clone; #[derive(Clone, Debug, Hash, Eq, PartialEq)] struct Edge<Cost> where Cost: std::clone::Clone, { to: usize, cost: Cost, } impl<Cost> Ord for Edge<Cost> where Cost: Ord + std::clone::Clone, { fn cmp(&self, other: &Edge<Cost>) -> Ordering { (self.cost).cmp(&(other.cost)).reverse() } } impl<Cost> PartialOrd for Edge<Cost> where Cost: std::clone::Clone, Edge<Cost>: Ord, { fn partial_cmp(&self, other: &Edge<Cost>) -> Option<std::cmp::Ordering> { Some(self.cmp(other)) } } trait Graph where Self::Cost: Clone { type Cost; fn len(&self) -> usize; fn get<'a>(&'a self, p: usize) -> std::slice::Iter<'a, Edge<Self::Cost>>; fn get_order(&self) -> Vec<usize>; } #[derive(Clone, Debug, Hash)] struct AdjList<Cost: Clone> { adj: Vec<Vec<Edge<Cost>>>, } impl<Cost: Clone> std::ops::Index<usize> for AdjList<Cost> { type Output = Vec<Edge<Cost>>; fn index(&self, i: usize) -> &Vec<Edge<Cost>> { &self.adj[i] } } impl<Cost: Clone> std::ops::IndexMut<usize> for AdjList<Cost> { fn index_mut<'a>(&'a mut self, i: usize) -> &'a mut Vec<Edge<Cost>> { &mut self.adj[i] } } impl<Cost: Clone> AdjList<Cost> { fn new(n: usize) -> AdjList<Cost> { AdjList { adj: vec![vec![]; n], } } fn add_edge(&mut self, from: usize, to_: usize, cost_: Cost) { self.adj[from].push(Edge { to: to_, cost: cost_, }); } fn add_uedge(&mut self, from: usize, to_: usize, cost_: Cost) { self.add_edge(from, to_, cost_.clone()); self.add_edge(to_, from, cost_); } } impl<Cost> Graph for AdjList<Cost> where Cost: Clone { type Cost = Cost; fn len(&self) -> usize { self.adj.len() } fn get<'a>(&'a self, p: usize) -> std::slice::Iter<'a, Edge<Cost>> { self.adj[p].iter() } fn get_order(&self) -> Vec<usize> { let mut res = Vec::with_capacity(self.len()); let mut deg = vec![0; self.len()]; let mut used = vec![false; self.len()]; for from in 0..self.len() { for e in self.get(from) { deg[e.to] += 1; } } for s in 0..self.len() { if deg[s] != 0 || used[s] { continue; } let mut stack = Vec::new(); used[s] = true; stack.push(s); while let Some(p) = stack.pop() { used[p] = true; res.push(p); for e in self.get(p) { deg[e.to] -= 1; if deg[e.to] == 0 { stack.push(e.to); } } } } // debug!(deg); res } } trait Zero { fn zero() -> Self; } impl Zero for i64 { fn zero() -> i64 { 0 } } trait Max { fn max_value() -> Self; } impl Max for i64 { fn max_value() -> i64 { std::i64::MAX } } trait GraphHavingOrderedCost: Graph where Self::Cost: Ord + Add<Self::Cost, Output = Self::Cost> + Zero + Max + Copy, { fn get_shortest_path(&self, from: usize) -> (Vec<Self::Cost>, Vec<usize>); fn bellmanford(&self, from: usize) -> Option<Vec<Self::Cost>>; fn get_shortest_path_graph(&self, from: usize, dist: &Vec<Self::Cost>) -> AdjList<Self::Cost>; } use std::ops::Add; impl<T> GraphHavingOrderedCost for T where T: Graph, T::Cost: Ord + Add<T::Cost, Output = T::Cost> + Zero + Max + Copy, Edge<T::Cost>: Ord, { fn get_shortest_path(&self, from: usize) -> (Vec<Self::Cost>, Vec<usize>) { let n = self.len(); let mut dist = vec![Self::Cost::max_value(); n]; let mut pre = vec![n as usize; n]; let mut heap = std::collections::BinaryHeap::new(); heap.push(Edge { to: from, cost: Self::Cost::zero(), }); dist[from] = Self::Cost::zero(); while let Some(p) = heap.pop() { for e in self.get(p.to) { if p.cost + e.cost >= dist[e.to] { continue; } heap.push(Edge { to: e.to, cost: p.cost + e.cost, }); dist[e.to] = p.cost + e.cost; pre[e.to] = p.to; } } (dist, pre) } fn bellmanford(&self, from: usize) -> Option<Vec<Self::Cost>> { let n = self.len(); let mut dist = vec![Self::Cost::max_value(); n]; let mut updated = true; dist[from] = Self::Cost::zero(); for _ in 0..n+1 { updated = false; for from in 0..n { if dist[from] == Self::Cost::max_value() { continue; } for e in self.get(from) { if dist[e.to] > dist[from]+e.cost { dist[e.to] = dist[from]+e.cost; updated = true; } } } } if updated { None } else { Some(dist) } } fn get_shortest_path_graph(&self, from: usize, dist: &Vec<Self::Cost>) -> AdjList<Self::Cost> { let n = self.len(); let mut res = AdjList::new(n); for from in 0..n { for e in self.get(from) { if dist[from] + e.cost == dist[e.to] { res.add_edge(from, e.to, e.cost); } } } res } } use std::io::prelude::*; impl<Cost: Clone> AdjList<Cost> { fn vizualize(&self, name: &str) { let path = std::path::Path::new("tmp.dot"); { let mut file = std::fs::File::create(path).unwrap(); let n = self.len(); file.write_all("digraph graph_name {\n".as_bytes()).unwrap(); for p in 0..n { let s = [" ".to_string(), p.to_string(), "[];\n".to_string()].connect(""); file.write_all(s.as_bytes()).unwrap(); } for p in 0..n { for e in &self[p] { file.write_all(b" ").unwrap(); file.write_all(p.to_string().as_bytes()).unwrap(); file.write_all(b" -> ").unwrap(); file.write_all(e.to.to_string().as_bytes()).unwrap(); file.write_all(b"\n").unwrap(); } } file.write(b"}\n").unwrap(); } let mut cmd = std::process::Command::new("dot"); cmd.arg("-T"); cmd.arg("png"); cmd.arg("tmp.dot"); cmd.arg("-o"); cmd.arg(name); cmd.status().expect("commend failed to start"); } } fn main() { use std::io::Write; let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); } macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); } let (n, m) = readl!(usize, usize); let mut g = AdjList::new(n); for _ in 0..m { let (a, b, c) = readl!(usize, usize, i64); g.add_edge(a-1, b-1, -c); } if let Some(v) = g.bellmanford(0) { printfln!("{}", -v[n-1]); } else { printfln!("inf"); } }
a.cc:1:2: error: invalid preprocessing directive #[ 1 | #[allow(dead_code)] | ^ a.cc:8:2: error: invalid preprocessing directive #[ 8 | #[allow(unused_macros)] | ^ a.cc:25:2: error: invalid preprocessing directive #[ 25 | #[allow(unused_macros)] | ^ a.cc:36:2: error: invalid preprocessing directive #[ 36 | #[allow(unused_macros)] | ^ a.cc:40:2: error: invalid preprocessing directive #[ 40 | #[allow(dead_code)] | ^ a.cc:51:2: error: invalid preprocessing directive #[ 51 | #[allow(unused_imports)] | ^ a.cc:53:2: error: invalid preprocessing directive #[ 53 | #[allow(unused_imports)] | ^ a.cc:55:2: error: invalid preprocessing directive #[ 55 | #[allow(unused_imports)] | ^ a.cc:60:2: error: invalid preprocessing directive #[ 60 | #[derive(Clone, Debug, Hash, Eq, PartialEq)] | ^ a.cc:94:12: warning: multi-character character constant [-Wmultichar] 94 | fn get<'a>(&'a self, p: usize) -> std::slice::Iter<'a, Edge<Self::Cost>>; | ^~~~~~~ a.cc:94:56: warning: missing terminating ' character 94 | fn get<'a>(&'a self, p: usize) -> std::slice::Iter<'a, Edge<Self::Cost>>; | ^ a.cc:94:56: error: missing terminating ' character 94 | fn get<'a>(&'a self, p: usize) -> std::slice::Iter<'a, Edge<Self::Cost>>; | ^~~~~~~~~~~~~~~~~~~~~~ a.cc:98:2: error: invalid preprocessing directive #[ 98 | #[derive(Clone, Debug, Hash)] | ^ a.cc:112:18: warning: multi-character character constant [-Wmultichar] 112 | fn index_mut<'a>(&'a mut self, i: usize) -> &'a mut Vec<Edge<Cost>> { | ^~~~~~~ a.cc:112:50: warning: missing terminating ' character 112 | fn index_mut<'a>(&'a mut self, i: usize) -> &'a mut Vec<Edge<Cost>> { | ^ a.cc:112:50: error: missing terminating ' character 112 | fn index_mut<'a>(&'a mut self, i: usize) -> &'a mut Vec<Edge<Cost>> { | ^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:147:12: warning: multi-character character constant [-Wmultichar] 147 | fn get<'a>(&'a self, p: usize) -> std::slice::Iter<'a, Edge<Cost>> { | ^~~~~~~ a.cc:147:56: warning: missing terminating ' character 147 | fn get<'a>(&'a self, p: usize) -> std::slice::Iter<'a, Edge<Cost>> { | ^ a.cc:147:56: error: missing terminating ' character 147 | fn get<'a>(&'a self, p: usize) -> std::slice::Iter<'a, Edge<Cost>> { | ^~~~~~~~~~~~~~~~~ a.cc:155:21: error: too many decimal points in number 155 | for from in 0..self.len() { | ^~~~~~~~~~~ a.cc:160:18: error: too many decimal points in number 160 | for s in 0..self.len() { | ^~~~~~~~~~~ a.cc:252:18: error: too many decimal points in number 252 | for _ in 0..n+1 { | ^~~~ a.cc:254:25: error: too many decimal points in number 254 | for from in 0..n { | ^~~~ a.cc:277:21: error: too many decimal points in number 277 | for from in 0..n { | ^~~~ a.cc:297:22: error: too many decimal points in number 297 | for p in 0..n { | ^~~~ a.cc:301:22: error: too many decimal points in number 301 | for p in 0..n { | ^~~~ a.cc:331:14: error: too many decimal points in number 331 | for _ in 0..m { | ^~~~ a.cc:2:1: error: 'fn' does not name a type 2 | fn getline() -> String { | ^~ a.cc:9:1: error: 'macro_rules' does not name a type 9 | macro_rules! readl { | ^~~~~~~~~~~ a.cc:26:1: error: 'macro_rules' does not name a type 26 | macro_rules! readlvec { | ^~~~~~~~~~~ a.cc:37:1: error: 'macro_rules' does not name a type 37 | macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } } | ^~~~~~~~~~~ a.cc:41:1: error: 'fn' does not name a type 41 | fn show<T>(iter: T) -> String | ^~ a.cc:52:1: error: 'use' does not name a type 52 | use std::cmp::{max, min}; | ^~~ a.cc:54:1: error: 'use' does not name a type 54 | use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet}; | ^~~ a.cc:56:1: error: 'use' does not name a type 56 | use std::collections::btree_map::Entry::{Occupied, Vacant}; | ^~~ a.cc:58:1: error: 'use' does not name a type 58 | use std::cmp::Ordering; | ^~~ a.cc:59:1: error: 'use' does not name a type 59 | use std::clone::Clone; | ^~~ a.cc:61:8: error: 'Edge' is not a class template 61 | struct Edge<Cost> | ^~~~ a.cc:61:13: error: 'Cost' was not declared in this scope 61 | struct Edge<Cost> | ^~~~ a.cc:63:5: error: expected initializer before 'Cost' 63 | Cost: std::clone::Clone, | ^~~~ a.cc:69:1: error: 'impl' does not name a type 69 | impl<Cost> Ord for Edge<Cost> | ^~~~ a.cc:78:1: error: 'impl' does not name a type 78 | impl<Cost> PartialOrd for Edge<Cost> | ^~~~ a.cc:88:1: error: 'trait' does not name a type 88 | trait Graph | ^~~~~ a.cc:99:8: error: 'AdjList' is not a class template 99 | struct AdjList<Cost: Clone> { | ^~~~~~~ a.cc:99:16: error: 'Cost' was not declared in this scope 99 | struct AdjList<Cost: Clone> { | ^~~~ a.cc:100:5: error: 'adj' does not name a type 100 | adj: Vec<Vec<Edge<Cost>>>, | ^~~ a.cc:103:5: error: expected initializer before '<' token 103 | impl<Cost: Clone> std::ops::Index<usize> for AdjList<Cost> { | ^ a.cc:111:1: error: 'impl' does not name a type 111 | impl<Cost: Clone> std::ops::IndexMut<usize> for AdjList<Cost> { | ^~~~ a.cc:115:1: error: expected declaration before '}' token 115 | } | ^ a.cc:117:1: error: 'impl' does not name a type 117 | impl<Cost: Clone> AdjList<Cost> { | ^~~~ a.cc:137:1: error: 'impl' does not name a type 137 | impl<Cost> Graph for AdjList<Cost> | ^~~~ a.cc:151:5: error: 'fn' does not name a type 151 | fn get_order(&self) -> Vec<usize> { | ^~ a.cc:182:1: error: expected declaration before '}' token 182 | } | ^ a.cc:184:1: error: 'trait' does not name a type 184 | trait Zero { | ^~~~~ a.cc:188:1: error: 'impl' does not name a type 188 | impl Zero for i64 { | ^~~~ a.cc:194:1: error: 'trait' does not name a type 194 | trait Max { | ^~~~~ a.cc:198:1: error: 'impl' does not name a type 198 | impl Max for i64 { | ^~~~ a.cc:204:1: error: 'trait' does not name a type 204 | trait GraphHavingOrderedCost: Graph | ^~~~~ a.cc:213:1: error: 'use' does not name a type 213 | use std::ops::Add; | ^~~ a.cc:214:1: error: 'impl' does not name a type 214 | impl<T> GraphHavingOrderedCost for T | ^~~~ a.cc:289:1: error: 'use' does not name a type 289 | use std::io::prelude::*; | ^~~ a.cc:290:1: error: 'impl' does not name a type 290 | impl<Cost: Clone> AdjList<Cost> { | ^~~~ a.cc:322:1: error: 'fn' does not name a type 322 | fn main() { | ^~
s707755851
p03722
C++
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <cmath> #include <functional> typedef long long ll; using namespace std; class Edge { public: ll cost; int next; Edge(int n,ll c) { next=n; cost=c; } }; vector<Edge> g[1000]; bool used[1000]; ll d[1000]; ll inf = 1e15+7; int main() { int n,m; bool f=false; cin>>n>>m; for(int i=0;i<m;i++) { int a,b; ll c; cin>>a>>b>>c; a--; b--; c*=-1; g[a].push_back(Edge(b,c)); } fill(used,used+1000,false); fill(d,d+1000,inf); d[0]=0; for(int i=0;i<n+10;i++) { for(int j=0;j<n;j++) { for(int k=0;k<g[j].size();k++) { Edge e =g[j][k]; if(d[j]!=inf && d[e.next]>d[j]+e.cost) { d[e.next]=d[j]+e.cost; if(i==n+5) { f=true; break; } } } } } if(f){ cout<<"inf"<<endl; assert(true); } else cout<<-1*d[n-1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:68:9: error: 'assert' was not declared in this scope 68 | assert(true); | ^~~~~~ a.cc:7:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 6 | #include <functional> +++ |+#include <cassert> 7 | typedef long long ll;
s081790997
p03722
C++
#include<bits/stdc++.h> using namespace std; const long long int INF = 1LL << 50; const int nmax = 1001; const int mmax = 2001; struct edge { int from,to; long long int cost; }; edge es[2010]; int a[mmax],b[mmax]; long long int c[namx]; long long int d[nmax]; int n,m; int main(){ int s,t; long long int dd; cin >> n >> m; for(int i=0; i<m; i++){ cin >> a[i] >> b[i] >> c[i]; c[i] = -c[i]; } for(int i=0; i<=n; i++){ d[i] = INF; } d[1] = 0; for(int loop=0; loop<n-1; loop++){ for(int i=0; i<m; i++){ if(d[a[i]] == INF){ continue; } if(d[b[i]] > d[a[i]] + c[i]){ d[b[i]] = d[a[i]] + c[i]; } } } long long int ans = d[n]; bool negative[nmax]; for (int i = 0; i <= n; ++i) { negative[i] = false; } for (int loop = 0; loop < n ; loop++) { for (int i = 0; i < m; i++) { if (d[a[i]] == INF){ continue; } if (d[b[i]] > d[a[i]] + c[i]) { d[b[i]] = d[a[i]] + c[i]; negative[b[i]] = true; } if (negative[b[i]]) { negative[a[i]] = true; } } } if(negative[n]){ cout << "inf" << endl; } else{ cout << -ans << endl; } return 0; }
a.cc:16:17: error: 'namx' was not declared in this scope; did you mean 'nmax'? 16 | long long int c[namx]; | ^~~~ | nmax a.cc: In function 'int main()': a.cc:29:32: error: 'c' was not declared in this scope 29 | cin >> a[i] >> b[i] >> c[i]; | ^ a.cc:44:36: error: 'c' was not declared in this scope 44 | if(d[b[i]] > d[a[i]] + c[i]){ | ^ a.cc:63:37: error: 'c' was not declared in this scope 63 | if (d[b[i]] > d[a[i]] + c[i]) { | ^
s089922117
p03722
C++
#include<iostream> using namespace std; using ll = long long; const ll INF = 1LL << 50; int main(){ int n,m; cin >> n >> m; const int nmax = 1000; const int mmax = 2000; int a[mmax],b[mmax]; ll c[mmax]; for(int i=0; i<m; i++){ cin >> a[i] >> b[i] >> c[i]; c[i] = -c[i]; } ll d[nmax]; for(int i=0; i<n; i++){ d[i] = INF; } d[0] = 0; for(int loop = 0; loop < n-1; loop++){ for(int i=0; i<m; i++){ if(d[a[i]-1] == INF){ continue; } if(d[b[i]-1] > d[a[i]-1] + c[i]){ d[b[i]-1] = d[a[i]-1] + c[i]; } } } ll ans = d[n-1]; bool negative[nmax]; for (int i = 0; i < n; ++i) { negative[i] = false; } for (int loop = 0; loop < n ; ++ loop) { for (int i = 0; i < m; ++i) { if (dist[a[i] - 1] == INF) continue; if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) { dist[b[i] - 1] = dist[a[i] - 1] + c[i]; negative[b[i] - 1] = true; } if (negative[a[i] - 1] == true) { negative[b[i] - 1] = true; } } } if(negative[n-1]){ cout << "inf" << endl; } else{ cout << -ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:51:9: error: 'dist' was not declared in this scope 51 | if (dist[a[i] - 1] == INF) continue; | ^~~~ a.cc:52:9: error: 'dist' was not declared in this scope 52 | if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) { | ^~~~
s756227180
p03722
C++
#include<iostream> using namespace std; using ll = long long; const ll INF = 1LL << 50; int main(){ int n,m; cin >> n >> m; const int nmax = 1000; const int mmax = 2000; int a[mmax],b[mmax]; ll c[mmax]; for(int i=0; i<m; i++){ cin >> a[i] >> b[i] >> c[i]; c[i] = -c[i]; } ll d[nmax]; for(int i=0; i<n; i++){ d[i] = INF; } d[0] = 0; for(int loop = 0; loop < n-1; loop++){ for(int i=0; i<m; i++){ if(d[a[i]-1] == INF){ continue; } if(d[b[i]-1] > d[a[i]-1] + c[i]){ d[b[i]-1] = d[a[i]-1] + c[i]; } } } ll ans = d[n-1]; bool negative[NMAX]; for (int i = 0; i < N; ++i) { negative[i] = false; } for (int loop = 0; loop < N ; ++ loop) { for (int i = 0; i < M; ++i) { if (dist[a[i] - 1] == INF) continue; if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) { dist[b[i] - 1] = dist[a[i] - 1] + c[i]; negative[b[i] - 1] = true; } if (negative[a[i] - 1] == true) { negative[b[i] - 1] = true; } } } if(negative[n-1]){ cout << "inf" << endl; } else{ cout << -ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:43:17: error: 'NMAX' was not declared in this scope 43 | bool negative[NMAX]; | ^~~~ a.cc:45:23: error: 'N' was not declared in this scope 45 | for (int i = 0; i < N; ++i) { | ^ a.cc:46:5: error: 'negative' was not declared in this scope 46 | negative[i] = false; | ^~~~~~~~ a.cc:49:28: error: 'N' was not declared in this scope 49 | for (int loop = 0; loop < N ; ++ loop) { | ^ a.cc:50:23: error: 'M' was not declared in this scope 50 | for (int i = 0; i < M; ++i) { | ^ a.cc:51:9: error: 'dist' was not declared in this scope 51 | if (dist[a[i] - 1] == INF) continue; | ^~~~ a.cc:52:9: error: 'dist' was not declared in this scope 52 | if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) { | ^~~~ a.cc:54:7: error: 'negative' was not declared in this scope 54 | negative[b[i] - 1] = true; | ^~~~~~~~ a.cc:57:9: error: 'negative' was not declared in this scope 57 | if (negative[a[i] - 1] == true) { | ^~~~~~~~ a.cc:63:4: error: 'negative' was not declared in this scope 63 | if(negative[n-1]){ | ^~~~~~~~
s408168773
p03722
C++
#include<bits/stdc++.h> using namespace std; #define INF 1LL << 50; struct edge {long long int from,to,cost;}; edge es[2010]; long long int d[1010]; long long int n,m; bool shortest_path(long long int s){ for(int i=0; i<=n; i++){ d[i] = INF; } d[s] = 0; long long int count = 0; while(1){ if(count > n){ return true; } bool update = false; for(int i=0; i<m; i++){ edge ed = es[i]; if(d[ed.from] != INF && d[ed.to] > d[ed.from] + ed.cost){ d[ed.to] = d[ed.from] + ed.cost; update = true; } } if(!update) break; count++; } return false; } int main(){ long long int s,t,dd; cin >> n >> m; for(int i=0; i<m; i++){ cin >> s >> t >> dd; es[i].to = t; es[i].from = s; es[i].cost = -dd; } if(shortest_path(1LL)){ cout << "inf" << endl; } else{ cout << -d[n] << endl; } return 0; }
a.cc: In function 'bool shortest_path(long long int)': a.cc:26:38: error: expected ')' before '[' token 26 | if(d[ed.from] != INF && d[ed.to] > d[ed.from] + ed.cost){ | ~ ^ | ) a.cc:26:37: error: label 'd' used but not defined 26 | if(d[ed.from] != INF && d[ed.to] > d[ed.from] + ed.cost){ | ^
s736429416
p03722
C++
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define p(s) cout<<(s)<<endl #define REP(i,n,N) for(int i=n;i<N;i++) #define RREP(i,n,N) for(int i=N-1;i>=n;i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define F first #define S second typedef long long ll; using namespace std; const ll inf = LONG_LONG_MAX/4; int N, M; int a[1010], b[1010], c[1010]; ll d[1010]; bool negative[1010]; int main() { cin>>N>>M; REP(i,0,M){ cin>>a[i]>>b[i]>>c[i]; a[i]--; b[i]--; c[i] = -c[i]; } REP(i,0,N){ d[i] = inf; } d[0] = 0; REP(j,0,N-1){ REP(i,0,M){ if(d[a[i]]==inf) continue; d[b[i]] = min(d[b[i]], d[a[i]] + c[i]); } } REP(j,0,N-1){ REP(i,0,M){ if(d[a[i]]==inf) continue; if(d[b[i]] > d[a[i]] + c[i]){ d[b[i]] = d[a[i]] + c[i]; negative[b[i]]=true; } if(negative[a[i]]) negative[b[i]]=true; } } if(negative[N-1]) p("inf"); else p(-d[N - 1]); return 0; }
a.cc:22:16: error: 'LONG_LONG_MAX' was not declared in this scope 22 | const ll inf = LONG_LONG_MAX/4; | ^~~~~~~~~~~~~
s101506655
p03722
C++
#include <iostream> #include <algorithm> #include <string> #include <cmath> #include <vector> #include <functional> #include <stack> #include <utility> #include <map> #include <queue> #include <set> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1000000007; const ll INF = LLONG_MAX; const ll MAX_E = 3000; const ll MAX_V = 2000; struct edge { ll from, to, cost; }; edge es[MAX_E]; ll d[MAX_V]; ll V, E; bool solve(int s) { for (int i = 0; i < V; i++)d[i] = -INF; d[s] = 0; ll cnt = 0; while (true) { bool update = false; cnt++; for (int i = 0; i < E; i++) { edge e = es[i]; if (d[e.from] != -INF && d[e.to] < d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; update = true; if (cnt >= V-1 && e.to == V - 1)return false; } } if (!update)break; if (cnt > V * 3 + 10) return true; } return true; } int main() { cin >> V >> E; for (int i = 0; i < E; i++) { ll a, b, c; cin >> a >> b >> c; a--; b--; es[i] = { a,b,c }; } if (solve(0)) cout << d[V - 1] << endl; else cout << "inf" << endl; return 0; }
a.cc:19:16: error: 'LLONG_MAX' was not declared in this scope 19 | const ll INF = LLONG_MAX; | ^~~~~~~~~ a.cc:12:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 11 | #include <set> +++ |+#include <climits> 12 |
s218613545
p03722
C++
#include<bits/stdc++.h> using namespace std; #define inf 1e9 #define ll long long #define M 1000000007 #define P pair<int,int> #define FOR(i,m,n) for(int i=m;i<n;i++) #define rep(i,n) FOR(i,0,n) const int vx[4] = {0,1,0,-1}; const int vy[4] = {1,0,-1,0}; #define PI 3.14159265 vector<pair<int,ll> > v[1100]; int n,m; ll ans = -1e15; void search(int a,ll s){ if(a==n) ans = max(ans,s); rep(i,v[a].size()){ search(v[a][i].first,s+v[a][i].second); } } bool infinity(int a,int c){ if(c>n) return true; bool res = false; rep(i,v[a].size()){ res = res||infinity(v[a][i].first,c+1); } return res; } int main(){ cin>>n>>m; rep(i,m){ int a,b,c; cin>>a>>b>>c; pair<int,ll> p = make_pair<int,ll>(b,c); v[a].push_back(p); } if(infinity(1,1)) cout<<"inf"<<endl; else{ search(1,(ll)0); cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:43:40: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int' 43 | pair<int,ll> p = make_pair<int,ll>(b,c); | ^ 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, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = long long int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = long long int; typename decay<_Tp2>::type = long long int]' 1132 | make_pair(_T1&& __x, _T2&& __y) | ~~~~~~^~~
s613042814
p03722
C++
#include<bits/stdc++.h> using namespace std; #define inf 1e9 #define ll long long #define M 1000000007 #define P pair<int,int> #define FOR(i,m,n) for(int i=m;i<n;i++) #define rep(i,n) FOR(i,0,n) const int vx[4] = {0,1,0,-1}; const int vy[4] = {1,0,-1,0}; #define PI 3.14159265 vector<pair<int,ll> > v[1100]; int n,m; ll ans = -1e15; void search(int a,ll s){ if(a==n) ans = max(ans,s); rep(i,v[a].size()){ search(v[a][i].first,s+v[a][i].second); } } bool infinity(int a,int c){ if(c>n) return true; bool res = false; rep(i,v[a].size()){ res = res||infinity(v[a][i].first,c+1); } return res; } int main(){ cin>>n>>m; rep(i,m){ int a,b,c; cin>>a>>b>>c; v[a].push_back(make_pair<int,ll>(b,c)); } if(infinity(1,1)) cout<<"inf"<<endl; else{ search(1,(ll)0); cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:43:38: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int' 43 | v[a].push_back(make_pair<int,ll>(b,c)); | ^ 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, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = long long int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = long long int; typename decay<_Tp2>::type = long long int]' 1132 | make_pair(_T1&& __x, _T2&& __y) | ~~~~~~^~~
s060876672
p03722
C++
#include "bits/stdc++.h" using namespace std; #define FOR(i,a,b) for(int i =(a);i<(b);i++) #define REP(i,n) for(int i=0;i<(n);i++) #define REPm(i,n) for(int i=(n)-1;i>=0;i--) #define REP1(i,n) for(int i=1;i<=(n);i++) typedef long long ll; struct edge{ int v; //行き先 ll d; //重み }; #define inf 1e15 #define MAX_N 1000 ll dis[MAX_N]; vector<edge> G[MAX_N]; int main(){ int N,M; scanf("%d %d",&N,&M); REP(i,M){ int a,b,c; scanf("%d %d %d",&a,&b,&c); G[a-1].push_back((edge){b-1,-c}); } REP(i,N) dis[i] = inf; dis[0] = 0; REP(i,N-1){ REP(u,N){ REP(j,G[u].size()){ ll v = G[u][j].v; if(dis[u] < inf && dis[v] > dis[u]+G[u][j].d){ dis[v] = dis[u] + G[u][j].d; } } } }//ベルマンフォード法 bool isNcycle[N_MAX] = {}; REP(u,N){ if(!isNcycle){ REP(j,G[u].size()){ ll v = G[u][j].v; if(dis[u] < inf && dis[v] > dis[u]+G[u][j].d){ isNcycle[v] = true; } } } } //NEGATIVE CYCLEチェック if(isNcycle[N-1]) cout << "inf" << endl; else cout << -dis[N-1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:37:19: error: 'N_MAX' was not declared in this scope; did you mean 'NL_NMAX'? 37 | bool isNcycle[N_MAX] = {}; | ^~~~~ | NL_NMAX a.cc:39:13: error: 'isNcycle' was not declared in this scope 39 | if(!isNcycle){ | ^~~~~~~~ a.cc:48:8: error: 'isNcycle' was not declared in this scope 48 | if(isNcycle[N-1]) cout << "inf" << endl; | ^~~~~~~~
s529611376
p03722
C++
#include <iostream> #include <climits> #define INF (LLONG_MAX>>2); using namespace std; typedef long long ll; const int nlimit=1005; int n, m; int a[nlimit], b[nlimit]; ll c[nlimit]; void solve(); int main(){ cin >> n >> m; ll tempc; for(int i=1; i<=m; i++){ cin >> a[i] >> b[i] >> tempc; c[i] = -tempc; } solve(); return 0; } void solve(){ ll dist[n]; for(int i=1; i<=n; i++) dist[i] = INF; dist[1] = 0; for(int i=1; i<=n-1; i++){ for(int j=1; j<=m; j++){ if(dist[a[j]]!=INF && dist[b[j]] > dist[a[j]] + c[j]){ dist[b[j]] = dist[a[j]] + c[j]; } } } bool isNeg[n+1]; for(int i=1; i<=n; i++) isNeg[i] = false; for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ if(dist[a[j]]!=INF && dist[b[j]] > dist[a[j]] + c[j]){ isNeg[b[j]] = true; } if(isNeg[a[j]]) isNeg[b[j]] = true; } } cout << ((isNeg[n])? "inf": to_string(-dist[n])) << endl; }
a.cc: In function 'void solve()': a.cc:34:33: error: expected ')' before '[' token 34 | if(dist[a[j]]!=INF && dist[b[j]] > dist[a[j]] + c[j]){ | ~ ^ | ) a.cc:45:33: error: expected ')' before '[' token 45 | if(dist[a[j]]!=INF && dist[b[j]] > dist[a[j]] + c[j]){ | ~ ^ | ) a.cc:34:29: error: label 'dist' used but not defined 34 | if(dist[a[j]]!=INF && dist[b[j]] > dist[a[j]] + c[j]){ | ^~~~
s910785171
p03722
C++
#include <iostream> #include<cstdlib> #include<queue> #include<set> #include<vector> #include<string> #include<algorithm> #include<stack> #include<map> #include<deque> #include<cstdio> using namespace std; #define rep(i,a) for(int i=0;i<a;i++) #define mp make_pair #define pb push_back #define ll __int64 //#define ll long long #define P pair<ll,ll> vector<P>G[1100]; int n,m; ll a,b,c; ll dist[1100]; bool heiro[11000]; bool used[11000]; const ll INF=-20000000000000000; bool che(int now){ queue<int>bfs; bfs.push(now); while(!bfs.empty()){ int next=bfs.front(); bfs.pop(); if(used[next])continue; if(heiro[next])return 0; rep(i,G[next].size()){ bfs.push(G[next][i].first); } } return 1; } int main(){ //O(VE)辺に着目して距離を更新 cin>>n>>m; rep(i,n)dist[i]=INF; rep(i,m){ cin>>a>>b>>c; a--; b--; G[a].push_back(mp(b,c)); //G[b].push_back(mp(a,c)); } dist[0]=0; rep(i,3*n){ rep(j,n){ rep(k,G[j].size()){ int from=j,to=G[j][k].first,cost=G[j][k].second; if(dist[to]<dist[from]+cost){ dist[to]=dist[from]+cost; if(i>n)heiro[to]=heiro[from]=1; } } } if(i>=3*n-1){ break; } } if(che(0)) cout<<dist[n-1]<<endl; else cout<<"inf"<<endl; return 0; }
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:18:16: note: in expansion of macro 'll' 18 | #define P pair<ll,ll> | ^~ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:18:19: note: in expansion of macro 'll' 18 | #define P pair<ll,ll> | ^~ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:18:21: error: template argument 1 is invalid 18 | #define P pair<ll,ll> | ^ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:18:21: error: template argument 2 is invalid 18 | #define P pair<ll,ll> | ^ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:20:9: error: template argument 1 is invalid 20 | vector<P>G[1100]; | ^ a.cc:20:9: error: template argument 2 is invalid a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:22:1: note: in expansion of macro 'll' 22 | ll a,b,c; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:23:1: note: in expansion of macro 'll' 23 | ll dist[1100]; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:26:7: note: in expansion of macro 'll' 26 | const ll INF=-20000000000000000; | ^~ a.cc: In function 'bool che(int)': a.cc:37:31: error: request for member 'size' in 'G[next]', which is of non-class type 'int' 37 | rep(i,G[next].size()){ | ^~~~ a.cc:13:32: note: in definition of macro 'rep' 13 | #define rep(i,a) for(int i=0;i<a;i++) | ^ a.cc:38:41: error: invalid types 'int[int]' for array subscript 38 | bfs.push(G[next][i].first); | ^ a.cc: In function 'int main()': a.cc:47:17: error: 'dist' was not declared in this scope 47 | rep(i,n)dist[i]=INF; | ^~~~ a.cc:47:25: error: 'INF' was not declared in this scope 47 | rep(i,n)dist[i]=INF; | ^~~ a.cc:50:22: error: 'a' was not declared in this scope 50 | cin>>a>>b>>c; | ^ a.cc:50:25: error: 'b' was not declared in this scope 50 | cin>>a>>b>>c; | ^ a.cc:50:28: error: 'c' was not declared in this scope 50 | cin>>a>>b>>c; | ^ a.cc:56:9: error: 'dist' was not declared in this scope 56 | dist[0]=0; | ^~~~ a.cc:60:36: error: request for member 'size' in 'G[j]', which is of non-class type 'int' 60 | rep(k,G[j].size()){ | ^~~~ a.cc:13:32: note: in definition of macro 'rep' 13 | #define rep(i,a) for(int i=0;i<a;i++) | ^ a.cc:61:51: error: invalid types 'int[int]' for array subscript 61 | int from=j,to=G[j][k].first,cost=G[j][k].second; | ^ a.cc:62:56: error: 'cost' was not declared in this scope; did you mean 'const'? 62 | if(dist[to]<dist[from]+cost){ | ^~~~ | const
s652896478
p03722
C++
#include <iostream> #include<cstdlib> #include<queue> #include<set> #include<vector> #include<string> #include<algorithm> #include<stack> #include<map> #include<deque> #include<cstdio> using namespace std; #define rep(i,a) for(int i=0;i<a;i++) #define mp make_pair #define pb push_back #define ll __int64 //#define ll long long #define P pair<ll,ll> vector<P>G[1100]; ll g[1100][1100]; int n,m; ll a,b,c; ll dist[1100]; const ll INF=-200000000000000000; int main(){ //O(VE)辺に着目して距離を更新 cin>>n>>m; rep(i,n)dist[i]=INF; rep(i,n)rep(j,n)g[i][j]=INF; rep(i,m){ cin>>a>>b>>c; a--; b--; //G[a].push_back(mp(b,c)); //G[b].push_back(mp(a,c)); g[a][b]=max(g[a][b],c); } rep(i,n){ rep(j,n)if(g[i][j]!=INF)G[i].push_back(mp(j,g[i][j])); } dist[0]=0; rep(i,n){ bool update=false; rep(j,n){ rep(k,G[j].size()){ int from=j,to=G[j][k].first,cost=G[j][k].second; if(dist[to]<dist[from]+cost){ update=true; dist[to]=dist[from]+cost; } } } if(!update)break; } bool ok=1; ll d[1100]; rep(i,n)d[i]=0; rep(i,n){ rep(j,n){ rep(k,G[j].size()){ int from=j,to=G[j][k].first,cost=G[j][k].second; if(d[to]<d[from]+cost){ d[to]=d[from]+cost; if(i==n-1)ok=0; } } } } if(ok) cout<<dist[n-1]<<endl; else cout<<"inf"<<endl; return 0; }
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:18:16: note: in expansion of macro 'll' 18 | #define P pair<ll,ll> | ^~ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:18:19: note: in expansion of macro 'll' 18 | #define P pair<ll,ll> | ^~ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:18:21: error: template argument 1 is invalid 18 | #define P pair<ll,ll> | ^ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:18:21: error: template argument 2 is invalid 18 | #define P pair<ll,ll> | ^ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:20:9: error: template argument 1 is invalid 20 | vector<P>G[1100]; | ^ a.cc:20:9: error: template argument 2 is invalid a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:21:1: note: in expansion of macro 'll' 21 | ll g[1100][1100]; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:23:1: note: in expansion of macro 'll' 23 | ll a,b,c; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:24:1: note: in expansion of macro 'll' 24 | ll dist[1100]; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:25:7: note: in expansion of macro 'll' 25 | const ll INF=-200000000000000000; | ^~ a.cc: In function 'int main()': a.cc:30:17: error: 'dist' was not declared in this scope 30 | rep(i,n)dist[i]=INF; | ^~~~ a.cc:30:25: error: 'INF' was not declared in this scope 30 | rep(i,n)dist[i]=INF; | ^~~ a.cc:31:25: error: 'g' was not declared in this scope 31 | rep(i,n)rep(j,n)g[i][j]=INF; | ^ a.cc:31:33: error: 'INF' was not declared in this scope 31 | rep(i,n)rep(j,n)g[i][j]=INF; | ^~~ a.cc:34:22: error: 'a' was not declared in this scope 34 | cin>>a>>b>>c; | ^ a.cc:34:25: error: 'b' was not declared in this scope 34 | cin>>a>>b>>c; | ^ a.cc:34:28: error: 'c' was not declared in this scope 34 | cin>>a>>b>>c; | ^ a.cc:39:17: error: 'g' was not declared in this scope 39 | g[a][b]=max(g[a][b],c); | ^ a.cc:42:28: error: 'g' was not declared in this scope 42 | rep(j,n)if(g[i][j]!=INF)G[i].push_back(mp(j,g[i][j])); | ^ a.cc:42:37: error: 'INF' was not declared in this scope 42 | rep(j,n)if(g[i][j]!=INF)G[i].push_back(mp(j,g[i][j])); | ^~~ a.cc:42:46: error: request for member 'push_back' in 'G[i]', which is of non-class type 'int' 42 | rep(j,n)if(g[i][j]!=INF)G[i].push_back(mp(j,g[i][j])); | ^~~~~~~~~ a.cc:44:9: error: 'dist' was not declared in this scope 44 | dist[0]=0; | ^~~~ a.cc:49:36: error: request for member 'size' in 'G[j]', which is of non-class type 'int' 49 | rep(k,G[j].size()){ | ^~~~ a.cc:13:32: note: in definition of macro 'rep' 13 | #define rep(i,a) for(int i=0;i<a;i++) | ^ a.cc:50:51: error: invalid types 'int[int]' for array subscript 50 | int from=j,to=G[j][k].first,cost=G[j][k].second; | ^ a.cc:51:56: error: 'cost' was not declared in this scope; did you mean 'const'? 51 | if(dist[to]<dist[from]+cost){ | ^~~~ | const a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:61:9: note: in expansion of macro 'll' 61 | ll d[1100]; | ^~ a.cc:62:17: error: 'd' was not declared in this scope 62 | rep(i,n)d[i]=0; | ^ a.cc:67:36: error: request for member 'size' in 'G[j]', which is of non-class type 'int' 67 | rep(k,G[j].size()){ | ^~~~ a.cc:13:32: note: in definition of macro 'rep' 13 | #define rep(i,a) for(int i=0;i<a;i++) | ^ a.cc:68:51: error: invalid types 'int[int]' for array subscript 68 | int from=j,to=G[j][k].first,cost=G[j][k].second; | ^ a.cc:69:36: error: 'd' was not declared in this scope 69 | if(d[to]<d[from]+cost){ | ^ a.cc:69:50: error: 'cost' was not declared in this scope; did you mean 'const'? 69 | if(d[to]<d[from]+cost){ | ^~~~ | const
s189501618
p03722
C++
#include <iostream> #include<cstdlib> #include<queue> #include<set> #include<vector> #include<string> #include<algorithm> #include<stack> #include<map> #include<deque> #include<cstdio> using namespace std; #define rep(i,a) for(int i=0;i<a;i++) #define mp make_pair #define pb push_back #define ll __int64 //#define ll long long #define P pair<ll,ll> vector<P>G[1100]; ll g[1100][1100]; int n,m; ll a,b,c; ll dist[1100]; const ll INF=-200000000000000000; int main(){ //O(VE)辺に着目して距離を更新 cin>>n>>m; rep(i,n)dist[i]=INF; rep(i,n)rep(j,n)g[i][j]=INF; rep(i,m){ cin>>a>>b>>c; a--; b--; //G[a].push_back(mp(b,c)); //G[b].push_back(mp(a,c)); g[a][b]=max(g[a][b],c); } rep(i,n){ rep(j,n)if(g[i][j]!=INF)G[i].push_back(mp(j,g[i][j])); } dist[0]=0; rep(i,3*n){ bool update=false; rep(j,n){ rep(k,G[j].size()){ int from=j,to=G[j][k].first,cost=G[j][k].second; if(dist[to]<dist[from]+cost){ update=true; dist[to]=dist[from]+cost; } } } if(!update)break; if(i==n*3-1){ cout<<"inf\n"; return 0; } } cout<<dist[n-1]<<endl; return 0; }
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:18:16: note: in expansion of macro 'll' 18 | #define P pair<ll,ll> | ^~ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:18:19: note: in expansion of macro 'll' 18 | #define P pair<ll,ll> | ^~ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:18:21: error: template argument 1 is invalid 18 | #define P pair<ll,ll> | ^ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:18:21: error: template argument 2 is invalid 18 | #define P pair<ll,ll> | ^ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:20:9: error: template argument 1 is invalid 20 | vector<P>G[1100]; | ^ a.cc:20:9: error: template argument 2 is invalid a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:21:1: note: in expansion of macro 'll' 21 | ll g[1100][1100]; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:23:1: note: in expansion of macro 'll' 23 | ll a,b,c; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:24:1: note: in expansion of macro 'll' 24 | ll dist[1100]; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:25:7: note: in expansion of macro 'll' 25 | const ll INF=-200000000000000000; | ^~ a.cc: In function 'int main()': a.cc:30:17: error: 'dist' was not declared in this scope 30 | rep(i,n)dist[i]=INF; | ^~~~ a.cc:30:25: error: 'INF' was not declared in this scope 30 | rep(i,n)dist[i]=INF; | ^~~ a.cc:31:25: error: 'g' was not declared in this scope 31 | rep(i,n)rep(j,n)g[i][j]=INF; | ^ a.cc:31:33: error: 'INF' was not declared in this scope 31 | rep(i,n)rep(j,n)g[i][j]=INF; | ^~~ a.cc:34:22: error: 'a' was not declared in this scope 34 | cin>>a>>b>>c; | ^ a.cc:34:25: error: 'b' was not declared in this scope 34 | cin>>a>>b>>c; | ^ a.cc:34:28: error: 'c' was not declared in this scope 34 | cin>>a>>b>>c; | ^ a.cc:39:17: error: 'g' was not declared in this scope 39 | g[a][b]=max(g[a][b],c); | ^ a.cc:42:28: error: 'g' was not declared in this scope 42 | rep(j,n)if(g[i][j]!=INF)G[i].push_back(mp(j,g[i][j])); | ^ a.cc:42:37: error: 'INF' was not declared in this scope 42 | rep(j,n)if(g[i][j]!=INF)G[i].push_back(mp(j,g[i][j])); | ^~~ a.cc:42:46: error: request for member 'push_back' in 'G[i]', which is of non-class type 'int' 42 | rep(j,n)if(g[i][j]!=INF)G[i].push_back(mp(j,g[i][j])); | ^~~~~~~~~ a.cc:44:9: error: 'dist' was not declared in this scope 44 | dist[0]=0; | ^~~~ a.cc:49:36: error: request for member 'size' in 'G[j]', which is of non-class type 'int' 49 | rep(k,G[j].size()){ | ^~~~ a.cc:13:32: note: in definition of macro 'rep' 13 | #define rep(i,a) for(int i=0;i<a;i++) | ^ a.cc:50:51: error: invalid types 'int[int]' for array subscript 50 | int from=j,to=G[j][k].first,cost=G[j][k].second; | ^ a.cc:51:56: error: 'cost' was not declared in this scope; did you mean 'const'? 51 | if(dist[to]<dist[from]+cost){ | ^~~~ | const
s020805661
p03722
C++
#include <iostream> #include<cstdlib> #include<queue> #include<set> #include<vector> #include<string> #include<algorithm> #include<stack> #include<map> #include<deque> #include<cstdio> using namespace std; #define rep(i,a) for(int i=0;i<a;i++) #define mp make_pair #define pb push_back #define ll __int64 //#define ll long long #define P pair<ll,ll> vector<P>G[1100]; int n,m; ll a,b,c; ll dist[1100]; const ll INF=-20000000000000000; int main(){ //O(VE)辺に着目して距離を更新 cin>>n>>m; rep(i,n)dist[i]=INF; rep(i,m){ cin>>a>>b>>c; a--; b--; G[a].push_back(mp(b,c)); //G[b].push_back(mp(a,c)); } dist[0]=0; rep(i,n+1){ bool update=false; rep(j,n){ rep(k,G[j].size()){ int from=j,to=G[j][k].first,cost=G[j][k].second; if(dist[to]<dist[from]+cost){ update=true; dist[to]=dist[from]+cost; } } } if(!update)break; if(i==n){ cout<<"inf\n"; return 0; } } cout<<dist[n-1]<<endl; return 0; }
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:18:16: note: in expansion of macro 'll' 18 | #define P pair<ll,ll> | ^~ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:18:19: note: in expansion of macro 'll' 18 | #define P pair<ll,ll> | ^~ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:18:21: error: template argument 1 is invalid 18 | #define P pair<ll,ll> | ^ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:18:21: error: template argument 2 is invalid 18 | #define P pair<ll,ll> | ^ a.cc:20:8: note: in expansion of macro 'P' 20 | vector<P>G[1100]; | ^ a.cc:20:9: error: template argument 1 is invalid 20 | vector<P>G[1100]; | ^ a.cc:20:9: error: template argument 2 is invalid a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:22:1: note: in expansion of macro 'll' 22 | ll a,b,c; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:23:1: note: in expansion of macro 'll' 23 | ll dist[1100]; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:24:7: note: in expansion of macro 'll' 24 | const ll INF=-20000000000000000; | ^~ a.cc: In function 'int main()': a.cc:29:17: error: 'dist' was not declared in this scope 29 | rep(i,n)dist[i]=INF; | ^~~~ a.cc:29:25: error: 'INF' was not declared in this scope 29 | rep(i,n)dist[i]=INF; | ^~~ a.cc:32:22: error: 'a' was not declared in this scope 32 | cin>>a>>b>>c; | ^ a.cc:32:25: error: 'b' was not declared in this scope 32 | cin>>a>>b>>c; | ^ a.cc:32:28: error: 'c' was not declared in this scope 32 | cin>>a>>b>>c; | ^ a.cc:38:9: error: 'dist' was not declared in this scope 38 | dist[0]=0; | ^~~~ a.cc:43:36: error: request for member 'size' in 'G[j]', which is of non-class type 'int' 43 | rep(k,G[j].size()){ | ^~~~ a.cc:13:32: note: in definition of macro 'rep' 13 | #define rep(i,a) for(int i=0;i<a;i++) | ^ a.cc:44:51: error: invalid types 'int[int]' for array subscript 44 | int from=j,to=G[j][k].first,cost=G[j][k].second; | ^ a.cc:45:56: error: 'cost' was not declared in this scope; did you mean 'const'? 45 | if(dist[to]<dist[from]+cost){ | ^~~~ | const
s242984993
p03722
C++
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) typedef pair<int, int> P; typedef pair<ll, P> E; #define cost first #define from second.first #define to second.second #define MOD (1000000007ll) #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } int main(void){ int n,m,a,b,i,cnt=0; ll c,d[1234],ans; vector<E> g; E e; bool update,flag = true,done[1234]; fill(d,d+1234,INFLL); fill(done,done+1234,false); cin >> n >> m; d[1] = 0ll; done[1] = true; for(i=0; i<m; ++i){ cin >> a >> b >> c; g.push_back(E(-c,P(a,b))); } while(true){ update = false; for(i=0; i<m; ++i){ e = g[i]; if(done[e.from] && d[e.to] > d[e.from] + e.cost){ d[e.to] = d[e.from] + e.cost; done[e.to] = true; update = true; } } if(!update || cnt>n){ break; } cnt++; } ans = -d[n]; fill(d,d+1234,0ll); fill(done,done+1234,false); cnt = 0; while(true){ update = false; for(i=0; i<m; ++i){ e = g[i]; if(d[e.to] > d[e.from] + e.cost){ d[e.to] = d[e.from] + e.cost; done[e.to] = true; update = true; } } if(!update || cnt>n){ break; } cnt++; } if(done[n]){ cout << "inf" << endl; }else{ cout << ans << endl; } } return 0; }
a.cc:74:9: error: expected unqualified-id before 'return' 74 | return 0; | ^~~~~~ a.cc:75:1: error: expected declaration before '}' token 75 | } | ^
s748445788
p03722
C++
#include <vector> #include <iostream> #include <utility> using namespace std; struct Edge { int from; int to; int cost; }; const long long inf = 1e18; long long n, m; bool has_neg_loop(long long n, const vector<Edge> &edges) { bool f = false; vector<long long> dist(n,0); for (int i=0; i<n; i++) { for (auto e: edges) { if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) { dist[e.to] = dist[e.from] + e.cost; if (i==n-1) f |= true; } } } return f; } vector<long long> bellman_ford(vector<long long> &dist, const vector<Edge> &edges) { for (int i=0; i<n; i++) { for (auto e: edges) { if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) { dist[e.to] = dist[e.from] + e.cost; } } } return dist; } int main () { cin >> n >> m; vector<Edge> edges(m); for (auto &e: edges) { int f, t, c; cin >> f >> t >> c; e = {f-1, t-1, -c}; } vector<long long> distance(n, inf); distance[0] = 0; distance = bellman_ford(distance, edges); assert(distance[n-1] != INF); if (has_neg_loop(n, edges)) { cout << "inf" << endl; } else { cout << -1*distance[n-1] << endl; } }
a.cc: In function 'int main()': a.cc:53:29: error: 'INF' was not declared in this scope 53 | assert(distance[n-1] != INF); | ^~~ a.cc:53:5: error: 'assert' was not declared in this scope 53 | assert(distance[n-1] != INF); | ^~~~~~ a.cc:4:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 3 | #include <utility> +++ |+#include <cassert> 4 | using namespace std;
s006087678
p03722
C++
#include <iostream> #include <climits> #include <stack> #include <queue> #include <string> #include <random> #include <utility> #include <string.h> #include <iomanip> #include <stdlib.h> #include <algorithm> using namespace std; typedef pair<int,int> P; long long int INF = 9223372036854775806/2; double Pi = 3.141592653589; const int mod = 1000000007; // memset(a,0,sizeof(a)); →全部0にする long long int i,j,k; int n,m; long long int x[1002][1002]; long long int a,b,c; int main(){ cin>>n>>m; if(n>=100){ for(i=0;i<1000;i++){ for(j=0;j<1000;j++){ for(k=0;k<1000;k++){ x[i][j] = min(i+j,i*j,k*k); } } } } cout<<"year"<<endl; return 0; }
In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]': a.cc:31:19: required from here 31 | x[i][j] = min(i+j,i*j,k*k); | ~~~^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function 284 | if (__comp(__b, __a)) | ~~~~~~^~~~~~~~~~
s450733300
p03722
C++
long long inf=100000000000007; #define int long long #define rep(i,n) for(int i=0;i<n;++i) typedef pair<int,int> P; string alph("abcdefghijklmnopqrstuvwxyz"); struct edge{int from,to,cost;}; vector<edge> G; vector<int> O[10]; P sg[10]; int d[1005]; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; pair<int,double> s[1005]; int c=0; int fi[1005][1005]; int ans[1005][1005]={}; bool graph[55][55]; bool visited[55]; int a[55],b[55]; int n,m; bool in=false; void longest_path(){ rep(i,n+5)d[i]=-inf; d[0]=0; bool update=true; rep(j,n){ update=false; rep(i,m){ edge e=G[i]; if(d[e.from]!=-inf&&d[e.to]<d[e.from]+e.cost) { d[e.to]=d[e.from]+e.cost; if(e.from==n-1&&j==n-1)in=true; update=true; } } if(!update)break; } } signed main(){ cin>>n>>m; rep(i,m){ int a,b,c;cin>>a>>b>>c; G.push_back(edge{a-1,b-1,c}); } rep(i,n+5)d[i]=-inf; d[0]=0; rep(j,n){ rep(i,m){ edge e=G[i]; if(d[e.from]!=-inf&&d[e.to]<d[e.from]+e.cost) { d[e.to]=d[e.from]+e.cost; if(e.from==n-1&&j==n-1)in=true; } } } if(in)cout<<"inf"<<endl; else cout<<d[n-1]<<endl; return 0; }
a.cc:4:9: error: 'pair' does not name a type 4 | typedef pair<int,int> P; | ^~~~ a.cc:5:1: error: 'string' does not name a type 5 | string alph("abcdefghijklmnopqrstuvwxyz"); | ^~~~~~ a.cc:7:1: error: 'vector' does not name a type 7 | vector<edge> G; | ^~~~~~ a.cc:8:1: error: 'vector' does not name a type 8 | vector<int> O[10]; | ^~~~~~ a.cc:9:1: error: 'P' does not name a type 9 | P sg[10]; | ^ a.cc:13:1: error: 'pair' does not name a type 13 | pair<int,double> s[1005]; | ^~~~ a.cc: In function 'void longest_path()': a.cc:29:20: error: 'G' was not declared in this scope 29 | edge e=G[i]; | ^ a.cc: In function 'int main()': a.cc:40:2: error: 'cin' was not declared in this scope; did you mean 'in'? 40 | cin>>n>>m; | ^~~ | in a.cc:43:9: error: 'G' was not declared in this scope 43 | G.push_back(edge{a-1,b-1,c}); | ^ a.cc:49:20: error: 'G' was not declared in this scope 49 | edge e=G[i]; | ^ a.cc:57:11: error: 'cout' was not declared in this scope 57 | if(in)cout<<"inf"<<endl; | ^~~~ a.cc:57:24: error: 'endl' was not declared in this scope 57 | if(in)cout<<"inf"<<endl; | ^~~~ a.cc:58:14: error: 'cout' was not declared in this scope 58 | else cout<<d[n-1]<<endl; | ^~~~ a.cc:58:28: error: 'endl' was not declared in this scope 58 | else cout<<d[n-1]<<endl; | ^~~~
s814306774
p03722
C++
#include <numeric> #include<iostream> #include<set> #include<queue> #include<vector> #include<map> #include<stack> #include<algorithm> #include <sstream> #include<string> using namespace std; long long inf=100000000000007; #define int long long #define rep(i,n) for(int i=0;i<n;++i) typedef pair<int,int> P; string alph("abcdefghijklmnopqrstuvwxyz"); struct edge{int from,to,cost;}; vector<edge> G; vector<int> O[10]; P sg[10]; int d[1005]; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; pair<int,double> s[1005]; int c=0; int fi[1005][1005]; int ans[1005][1005]={}; bool graph[55][55]; bool visited[55]; int a[55],b[55]; int n,m; bool in=false; void longest_path(){ rep(i,n+5)d[i]=inf*-1; d[0]=0; bool update=true; while(true){ update=false; rep(i,m){ edge e=G[i]; if(d[e.from]!=inf*-1&&d[e.to]<d[e.from]+e.cost) { d[e.to]=d[e.from]+e.cost; update=true; } } if(!update)break; } } int dn[1005]; bool find_nega(){ memset(dn,0,sizeof(dn)); rep(i,n){ rep(j,m){ edge e=G[j]; if(d[e.to]<d[e.from]+e.cost){ d[e.to]=d[e.from]+e.cost; if(i==n-1)return true; } } } return false; } signed main(){ cin>>n>>m; rep(i,m){ int a,b,c;cin>>a>>b>>c; G.push_back(edge{a-1,b-1,c}); } if(find_nega()){ cout<<"inf"<<endl; return 0; } longest_path(); cout<<d[n-1]<<endl; return 0; }
a.cc: In function 'bool find_nega()': a.cc:52:5: error: 'memset' was not declared in this scope 52 | memset(dn,0,sizeof(dn)); | ^~~~~~ a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 10 | #include <sstream> +++ |+#include <cstring> 11 | #include<string>
s881575567
p03722
C++
#include <iostream> #include <algorithm> #include <functional> #include <string> #include <vector> #include <set> #include <queue> #include <stack> #include <unordered_set> using namespace std; typedef long long ll; typedef pair<int, int> P; static const int INF = 1000010000; static const int NIL = -1; static const int MOD = 1000000007; #define FOR(i, a, b) for(int i = (a); i < (b); ++i) #define REP(i, n) for(int i = 0; i < (n); ++i) #define SORT(v) sort(v.begin(), v.end()); #define pb push_back #define mp make_pair #define np next_permutation #define pq priority_queue int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; } int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; } int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; } int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; } long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; } long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; } long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; } long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; } //int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0}; //int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0}; //int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0}; //int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0}; struct edge{ int from, to; ll cost; }; #define MAX_E 2010 #define MAX_V 1010 edge es[MAX_E]; ll d[MAX_V]; int V, E; bool flag = false; bool visit[MAX_V]; void ford(int s){ REP(i, V) d[i] = 0; REP(i, V){ REP(j, E){ edge e = es[j]; if(d[e.to] > d[e.from] + e.cost || !visit[e.to]){ visit[e.to] = true; d[e.to] = d[e.from] + e.cost; if(i == V - 1){ flag = true; break; } } } } } int main(){ int n, m; cin >> n >> m; V = n; E = m; REP(i, m){ edge e; cin >> e.from >> e.to >> e.cost; e.from--; e.to--; e.cost *= -1; es[i] = e; } REP(i, MAX_V) visit[i] = false; fill(d, d + MAX_V, 0); ford(0); if(flag){ assert(flag == -2); cout << "inf" << endl; }else{ cout << -1 * d[n - 1] << endl; } }
a.cc: In function 'int main()': a.cc:85:7: error: 'assert' was not declared in this scope 85 | assert(flag == -2); | ^~~~~~ a.cc:10:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 9 | #include <unordered_set> +++ |+#include <cassert> 10 |
s917185479
p03722
C++
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> mat; #define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++) #define rep(i,n) FOR(i,0,n) #define ALL(x) (x).begin(),(x).end() #define RALL(x) (x).rbegin(),(x).rend() #define mset(a,x) memset(a,x,sizeof(a)) #define FASTIO cin.tie(0),ios::sync_with_stdio(0) using pii = pair<int, int>; using edge = pair<pii, int>; const ll INF = 1LL << 60; int n, m; vector<edge> es; ll dist(int s, union_find uf) { vector<ll> d(n, INF); d[s] = 0; bool updated = false; rep(k, n - 1) { for (auto&& e : es) { int src = e.first.first, dst = e.first.second; if (d[src] < INF && d[dst] > (d[src] + e.second)) { d[dst] = d[src] + e.second; } } } ll ret = d[n - 1]; vector<int> neg(n, 0); rep(k, n) { for (auto&& e : es) { int src = e.first.first, dst = e.first.second; if (d[src] < INF && d[dst] > (d[src] + e.second)) { d[dst] = d[src] + e.second; neg[dst] = 1; } if (neg[src]) neg[dst] = 1; } } if (neg[n - 1]) return INF; return ret; } int main() { cin >> n >> m; union_find uf(n); rep(i, m) { int a, b, c; scanf("%d%d%d", &a, &b, &c); --a; --b; es.push_back(make_pair(make_pair(a, b), -c)); uf.unite(a, b); } ll d = dist(0, uf); if (d == INF) cout << "inf" << endl; else cout << -d << endl; return 0; }
a.cc:22:16: error: 'union_find' has not been declared 22 | ll dist(int s, union_find uf) { | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:54:5: error: 'union_find' was not declared in this scope 54 | union_find uf(n); | ^~~~~~~~~~ a.cc:60:9: error: 'uf' was not declared in this scope 60 | uf.unite(a, b); | ^~ a.cc:63:20: error: 'uf' was not declared in this scope 63 | ll d = dist(0, uf); | ^~
s563180817
p03722
C++
#include<cstdio> #include<iostream> #include<vector> #include<algorithm> #include<map> #include<string> #define INF 2000000000 using namespace std; typedef pair<ll,ll> P; typedef long long ll; typedef pair<P,ll> PP; int n,m; vector<PP> e; ll d[1050]; bool bellman_ford(int s) { fill(d,d+n,INF); d[s]=0; for(int k=0;k<n;k++){ //bool update=false; for(int i=0;i<m;i++){ int from=e[i].first.first; int to=e[i].first.second; ll cost=e[i].second; if(d[from]!=INF&&d[to]>d[from]+cost){ d[to]=d[from]+cost; //update=true; if(k==n-1&&to==n-1)return true; } } } else return false; } /* bool find_negative_loop() { fill(d,d+n,0); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ int from=e[j].first.first; int to=e[j].first.second; ll cost=e[j].second; if(d[to]>d[from]+cost){ d[to]=d[from]+cost; if(i==n-1)return true; } } } return false; } */ int main() { cin>>n>>m; ll a,b; ll c; for(int i=0;i<m;i++){ cin>>a>>b>>c; a--; b--; c*=-1; e.push_back(PP(P(a,b),c)); } if(bellman_ford(0)){ cout<<"inf"<<endl; return 0; } bellman_ford(0); cout<<d[n-1]*(-1)<<endl; return 0; }
a.cc:11:14: error: 'll' was not declared in this scope 11 | typedef pair<ll,ll> P; | ^~ a.cc:11:17: error: 'll' was not declared in this scope 11 | typedef pair<ll,ll> P; | ^~ a.cc:11:19: error: template argument 1 is invalid 11 | typedef pair<ll,ll> P; | ^ a.cc:11:19: error: template argument 2 is invalid a.cc: In function 'bool bellman_ford(int)': a.cc:27:45: error: request for member 'first' in 'e.std::vector<std::pair<int, long long int> >::operator[](((std::vector<std::pair<int, long long int> >::size_type)i)).std::pair<int, long long int>::first', which is of non-class type 'int' 27 | int from=e[i].first.first; | ^~~~~ a.cc:28:43: error: request for member 'second' in 'e.std::vector<std::pair<int, long long int> >::operator[](((std::vector<std::pair<int, long long int> >::size_type)i)).std::pair<int, long long int>::first', which is of non-class type 'int' 28 | int to=e[i].first.second; | ^~~~~~ a.cc:37:9: error: 'else' without a previous 'if' 37 | else return false; | ^~~~ a.cc: In function 'int main()': a.cc:68:37: error: expression list treated as compound expression in functional cast [-fpermissive] 68 | e.push_back(PP(P(a,b),c)); | ^
s217850970
p03722
C++
#include<iostream> #include<cstdio> #include<vector> #include<string> #include<functional> #include<queue> #include<map> #include<limits> #include<cmath> #include<algorithm> #include<bitset> #include<utility> #include<complex> #include<cstdlib> #include<set> #include<cctype> #define DBG cerr << '!' << endl; #define REP(i,n) for(int (i) = (0);(i) < (n);++i) #define rep(i,s,g) for(int (i) = (s);(i) < (g);++i) #define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i)) #define PB push_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;} #define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;} #define ALL(v) v.begin(),v.end() using namespace std; typedef long long ll; typedef vector<int> iv; typedef vector<iv> iiv; typedef vector<string> sv; struct edge{ int from,to,cost; }; edge es[2010]; //辺 ll d[1010]; //最短距離 int n,m,sum; bool BF(int s,int V,int E){ //vは頂点数eは辺の数 REP(i,V)d[i] = -10000000000000;d[s] = 0; int cou = 0; while(true){ bool update = false; REP(i,E){ edge e = es[i]; if(d[e.from] != -10000000000000 && d[e.to] < d[e.from] + e.cost){ d[e.to] = d[e.from] + e.cost;update = true; cou++; } } if(!update)break; if(d[n-1] > sum)return false; } else return true; } int main() { cin >> n >> m; REP(i,m) { int a,b,c; cin >> a >> b >> c; es[i].from = a-1;es[i].to = b-1;es[i].cost = c;sum+=c; } if(BF(0,n,m)) { cout << d[n-1] << endl; } else { cout << "inf" << endl; } return 0; }
a.cc: In function 'bool BF(int, int, int)': a.cc:59:9: error: 'else' without a previous 'if' 59 | else return true; | ^~~~
s864623475
p03722
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1LL << 60; struct edge { ll from, to, cost; }; bool bellman_ford(const int v, const int s, vector<edge> es, vector<ll>& dist) { vector<ll> d(v, INF); d[s] = 0; bool neg_loop = false; for(int cnt=0; ;cnt++) { bool update = false; for(auto& e : es) { if(d[e.from] == INF) continue; if(d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; update = true; if(cnt >= v-1 && e.to == N-1) return true; } } if(!update) break; /*if(cnt >= v-1) { neg_loop = true; break; }*/ } dist = std::move(d); return neg_loop; } int main(void){ ll N, M; cin >> N >> M; vector<edge> es; for(int i=0;i<M;i++){ ll a, b, c; cin >> a >> b >> c; a--; b--; es.push_back(edge{a, b, -c}); } vector<ll> dist; bool loop = bellman_ford(N, 0, es, dist); if(loop) { cout << "inf" << endl; } else { cout << -dist[N-1] << endl; } return 0; }
a.cc: In function 'bool bellman_ford(int, int, std::vector<edge>, std::vector<long long int>&)': a.cc:24:42: error: 'N' was not declared in this scope 24 | if(cnt >= v-1 && e.to == N-1) return true; | ^
s246583855
p03722
C++
#include <bits/stdc++.h> #define INF 1234567890123LL #define MN 1001 using namespace std; typedef long long ll; typedef pair<int, ll> arc; ll dist[MN]; vector<arc> es[MN]; int prev[MN]; int main() { int n, m; cin >> n >> m; for(int i=0; i<m; i++) { int a, b; ll c; cin >> a >> b >> c; es[a].push_back(arc(b, -c)); } dist[1] = 0; for(int i=2; i<=n; i++) dist[i] = INF; for(int t=1; t<=n; t++) { for(int i=1; i<=n; i++) { for(vector<arc>::iterator itr=es[i].begin(); itr!=es[i].end(); itr++) { if(dist[itr->first] > dist[i] + itr->second) { dist[itr->first] = dist[i] + itr->second; prev[itr->first] = i; if(t==n) { dist[itr->first] = -INF; } } } } } if(dist[n]<=-INF) { cout << "inf" << endl; } else { cout << -dist[n] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:37:21: error: reference to 'prev' is ambiguous 37 | prev[itr->first] = i; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:12:5: note: 'int prev [1001]' 12 | int prev[MN]; | ^~~~
s475324822
p03722
C++
#include<algorithm> #define MM 20000000000000000 using namespace std; int main(void) { int n,m,flg[1001],a[2000],b[2000],c[2000],i,j; long long leng[1001]; scanf("%d %d",&n,&m); for(i=0;i<m;i++) { scanf("%d %d %d",&a[i],&b[i],&c[i]); c[i]=-c[i]; } for(i=1;i<=n;i++) leng[i]=2000000000000000000; leng[1]=0; for(i=0;i<n;i++) { for(j=0;j<m;j++) { leng[b[j]]=min(leng[b[j]],leng[a[j]]+c[j]); } } for(i=1;i<=n;i++) flg[i]=0; for(i=0;i<m;i++) { if(leng[b[i]]>leng[a[i]]+c[i]) { flg[b[i]]=1; } if(flg[a[i]]==1) flg[b[i]]=1; } if(flg[n]==1) printf("inf\n"); else printf("%lld\n",-leng[n]); return 0; }
a.cc: In function 'int main()': a.cc:8:9: error: 'scanf' was not declared in this scope 8 | scanf("%d %d",&n,&m); | ^~~~~ a.cc:27:25: error: 'printf' was not declared in this scope 27 | if(flg[n]==1) printf("inf\n"); | ^~~~~~ a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' 1 | #include<algorithm> +++ |+#include <cstdio> 2 | #define MM 20000000000000000 a.cc:28:14: error: 'printf' was not declared in this scope 28 | else printf("%lld\n",-leng[n]); | ^~~~~~ a.cc:28:14: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s918185924
p03722
C++
#include<bits/stdc++.h> #define INF 2100000000 #define LL long long int using namespace std; LL node[1010],i,j,k,n,m,a[1010],b[1010],c[1010],sco[1010]={INF},size[1010],x,y, check[1010]={0},sco2[1010]={INF},start,gorl; int root(int x){ if(x!=node[x]){ node[x]=root(node[x]); return node[x]; } else return x; } int main(void) { cin>>n>>m; for(i=1;i<=m;i++) { cin>>a[i]>>b[i]>>c[i]; if(n==b[i]) gorl=a[i]; if(n==a[i]) start=b[i]; } for(i=1;i<=n;i++) size[i]=1,node[i]=i; for(i=1;i<=m;i++) { x=a[i],y=b[i]; x=root(x); y=root(y); if(x!=y) { if(size[x]>=size[y]) node[y]=x; else node[x]=y; } } x=root(start); y=root(gorl); if(x==y) cout<<"inf"<<endl; else { for(i=1;i<=m;i++) { if(c[i]>0) { c[i]*=-1; check[i]=1; } } sco[1]=sco2[1]=0; for(i=1;i<=n-1;i++) { for(j=1;j<=m;j++) { if(sco[a[j]==INF) continue; if(sco[b[j]]>sco[a[j]]+c[j]) { sco[b[j]]=sco[a[j]]+c[j]; if(check[j]==1) sco2[b[j]]=sco2[a[j]]+c[j]*-1; else sco2[b[j]]=sco[b[j]]; } } } cout<<sco2[n]<<endl; } }
a.cc: In function 'int main()': a.cc:22:27: error: reference to 'size' is ambiguous 22 | for(i=1;i<=n;i++) size[i]=1,node[i]=i; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:65: note: 'long long int size [1010]' 5 | LL node[1010],i,j,k,n,m,a[1010],b[1010],c[1010],sco[1010]={INF},size[1010],x,y, | ^~~~ a.cc:28:28: error: reference to 'size' is ambiguous 28 | if(size[x]>=size[y]) node[y]=x; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:65: note: 'long long int size [1010]' 5 | LL node[1010],i,j,k,n,m,a[1010],b[1010],c[1010],sco[1010]={INF},size[1010],x,y, | ^~~~ a.cc:28:37: error: reference to 'size' is ambiguous 28 | if(size[x]>=size[y]) node[y]=x; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:65: note: 'long long int size [1010]' 5 | LL node[1010],i,j,k,n,m,a[1010],b[1010],c[1010],sco[1010]={INF},size[1010],x,y, | ^~~~ a.cc:45:49: error: expected ']' before ')' token 45 | if(sco[a[j]==INF) continue; | ^