submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s481963794
p03836
C++
#include<iostream> using namespace std; int main() { int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty; int l=tx-sx, h=ty-sy, i, j, k=0; for (i=0; i<h; i++) { a[k++]='U'; } for (j=0; j<l; j++) { a[k++]='R'; } for (i=0; i<h; i++) { a[k++]='D'; } for (j=0; j<l; j++) { a[k++]='L'; } a[k++]='L'; for (i=0; i<=h; i++) { a[k++]='U'; } for (j=0; j<=l; j++) { a[k++]='R'; } a[k++]='D'; a[k++]='R'; for (i=0; i<=h; i++) { a[k++]='D'; } for (j=0; j<=l; j++) { a[k++]='L'; } a[k++]='U'; for (i=0; i<k; i++) cout<<a[i]; return 0; }
a.cc: In function 'int main()': a.cc:12:9: error: 'a' was not declared in this scope 12 | a[k++]='U'; | ^ a.cc:16:9: error: 'a' was not declared in this scope 16 | a[k++]='R'; | ^ a.cc:20:9: error: 'a' was not declared in this scope 20 | a[k++]='D'; | ^ a.cc:24:9: error: 'a' was not declared in this scope 24 | a[k++]='L'; | ^ a.cc:26:5: error: 'a' was not declared in this scope 26 | a[k++]='L'; | ^
s148637336
p03836
C++
#include<isotream> #include<algorithm> using namespace std; int sx, sy, tx, ty; int main(){ cin >> sx >> sy >> tx >> ty; for(int i = sx;i < tx;i++)cout << "R"; for(int i = sy;i < ty;i++)cout << "U"; for(int i = tx;i > sx;i--)cout << "L"; for(int i = ty;i > sy;i--)cout << "D"; cout << "D"; for(int i = sx;i < tx+1;i++)cout << "R"; for(int i = sy-1;i < ty;i++)cout << "U"; cout << "L"; cout << "U"; for(int i = tx;i > sx-1;i--)cout << "L"; for(int i = ty+1;i > sy;i--)cout << "D"; cout << "R" << endl; return 0; }
a.cc:1:9: fatal error: isotream: No such file or directory 1 | #include<isotream> | ^~~~~~~~~~ compilation terminated.
s625716986
p03836
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0; i<n;i++) using namespace std; typedef pair<int,int> pii; int INF=1e9; string ans; int dx[]={0,0,1,-1}; int dy[]={1,-1,0,0}; bool inrange(int y,int x){return (0<=x&&x<=2000&&0<=y&&y<=2000);} vector<vector<bool>>flag(2001,vector<bool>(2001,true)); int mini; pii _start,_end; bool visit=false; bool dfs(pii now,int d,string s){ if(d>mini)return false; if(d==mini&&now==_end&&visit){ visit=false; ans+=s; return true; } rep(i,4){ string temp=s; pii next=pii(now.first+dy[i],now.second+dx[i]); if(!inrange(next.first, next.second))continue; if(dy[i]==1&&dx[i]==0)temp+="U"; else if(dy[i]==-1&&dx[i]==0)temp+="D"; else if(!dy[i] && dx[i]==1)temp+="R"; else temp+="L"; if(dfs(next,d+1,temp))flag[now.first][now.second]=false; } return false; } void bfs(pii s,pii g){ queue<pii>que; visit=true; vector<vector<int>>d(2001,vector<int>(2001,INF)); que.push(s); d[s.first][s.second]=0; while(!que.empty()){ pii now=que.front(); que.pop(); if(now==g)break; rep(i,4){ pii next=pii(now.first+dx[i],now.second+dy[i]); if(d[next.first][next.second]==INF&&inrange(next.first,next.second)){ if(!flag[next.first][next.second])continue; que.push(next); d[next.first][next.second]=d[now.first][now.second]+1; } } } mini=d[g.first][g.second]; _start=s; _end=g; dfs(_start,0,""); flag[s.first][s.second]=true; } int main(){ pii s,g; cin>>s.second>>s.first>>g.second>>g.first; s.first+=1000; s.second+=1000; g.first+=1000; g.second+=1000; bfs(s,g); bfs(g,s); bfs(s,g); bfs(g,s); cout<<ans<<endl; }
a.cc: In function 'bool dfs(pii, int, std::string)': a.cc:16:28: error: reference to 'visit' is ambiguous 16 | if(d==mini&&now==_end&&visit){ | ^~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80, from a.cc:1: /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:13:6: note: 'bool visit' 13 | bool visit=false; | ^~~~~ a.cc:17:9: error: reference to 'visit' is ambiguous 17 | visit=false; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:13:6: note: 'bool visit' 13 | bool visit=false; | ^~~~~ a.cc: In function 'void bfs(pii, pii)': a.cc:34:5: error: reference to 'visit' is ambiguous 34 | visit=true; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:13:6: note: 'bool visit' 13 | bool visit=false; | ^~~~~
s301502939
p03836
Java
import java.util.*; public class c{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(); int sx = Integer.parseInt(sc.next()); int sy = Integer.parseInt(sc.next()); int tx = Integer.parseInt(sc.next()); int ty = Integer.parseInt(sc.next()); int dx = tx - sx; int dy = ty - sy; for(int i = 0; i < dx; i++){ sb.append('R'); } for(int i = 0; i < dy; i++ ){ sb.append('U'); } for(int i = 0; i < dx; i++ ){ sb.append('L'); } for(int i = 0; i < dy; i++){ sb.append('D'); } sb.append('D'); for(int i = 0; i < dx+1; i++){ sb.append('R'); } for(int i = 0; i < dy+1; i++ ){ sb.append('U'); } sb.append('L'); sb.append('U'); for(int i = 0; i < dx+1; i++ ){ sb.append('L'); } for(int i = 0; i < dy+1; i++){ sb.append('D'); } sb.append('R'); System.out.println(new String(sb)); } }
Main.java:2: error: class c is public, should be declared in a file named c.java public class c{ ^ 1 error
s571133005
p03836
Java
import java.util.*; public class Main{ Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(); int sx = Integer.parseInt(sc.next()); int sy = Integer.parseInt(sc.next()); int tx = Integer.parseInt(sc.next()); int ty = Integer.parseInt(sc.next()); int dx = tx - sx; int dy = ty - sy; for(int i = 0; i < dx; i++){ sb.append('R'); } for(int i = 0; i < dy; i++ ){ sb.append('U'); } for(int i = 0; i < dx; i++ ){ sb.append('L'); } for(int i = 0; i < dy; i++){ sb.append('D'); } sb.append('D'); for(int i = 0; i < dx+1; i++){ sb.append('R'); } for(int i = 0; i < dy+1; i++ ){ sb.append('U'); } sb.append('L'); sb.append('U'); for(int i = 0; i < dx+1; i++ ){ sb.append('L'); } for(int i = 0; i < dy+1; i++){ sb.append('D'); } sb.append('R'); System.out.println(new String(sb)); }
Main.java:11: error: illegal start of type for(int i = 0; i < dx; i++){ ^ Main.java:11: error: > or ',' expected for(int i = 0; i < dx; i++){ ^ Main.java:11: error: <identifier> expected for(int i = 0; i < dx; i++){ ^ Main.java:14: error: illegal start of type for(int i = 0; i < dy; i++ ){ ^ Main.java:14: error: > or ',' expected for(int i = 0; i < dy; i++ ){ ^ Main.java:14: error: <identifier> expected for(int i = 0; i < dy; i++ ){ ^ Main.java:17: error: illegal start of type for(int i = 0; i < dx; i++ ){ ^ Main.java:17: error: > or ',' expected for(int i = 0; i < dx; i++ ){ ^ Main.java:17: error: <identifier> expected for(int i = 0; i < dx; i++ ){ ^ Main.java:20: error: illegal start of type for(int i = 0; i < dy; i++){ ^ Main.java:20: error: > or ',' expected for(int i = 0; i < dy; i++){ ^ Main.java:20: error: <identifier> expected for(int i = 0; i < dy; i++){ ^ Main.java:23: error: <identifier> expected sb.append('D'); ^ Main.java:23: error: illegal start of type sb.append('D'); ^ Main.java:24: error: illegal start of type for(int i = 0; i < dx+1; i++){ ^ Main.java:24: error: > or ',' expected for(int i = 0; i < dx+1; i++){ ^ Main.java:24: error: <identifier> expected for(int i = 0; i < dx+1; i++){ ^ Main.java:27: error: illegal start of type for(int i = 0; i < dy+1; i++ ){ ^ Main.java:27: error: > or ',' expected for(int i = 0; i < dy+1; i++ ){ ^ Main.java:27: error: <identifier> expected for(int i = 0; i < dy+1; i++ ){ ^ Main.java:30: error: <identifier> expected sb.append('L'); ^ Main.java:30: error: illegal start of type sb.append('L'); ^ Main.java:31: error: <identifier> expected sb.append('U'); ^ Main.java:31: error: illegal start of type sb.append('U'); ^ Main.java:32: error: illegal start of type for(int i = 0; i < dx+1; i++ ){ ^ Main.java:32: error: > or ',' expected for(int i = 0; i < dx+1; i++ ){ ^ Main.java:32: error: <identifier> expected for(int i = 0; i < dx+1; i++ ){ ^ Main.java:35: error: illegal start of type for(int i = 0; i < dy+1; i++){ ^ Main.java:35: error: > or ',' expected for(int i = 0; i < dy+1; i++){ ^ Main.java:35: error: <identifier> expected for(int i = 0; i < dy+1; i++){ ^ Main.java:38: error: <identifier> expected sb.append('R'); ^ Main.java:38: error: illegal start of type sb.append('R'); ^ Main.java:39: error: <identifier> expected System.out.println(new String(sb)); ^ Main.java:39: error: illegal start of type System.out.println(new String(sb)); ^ 34 errors
s754884925
p03836
C++
#include <cstdio> #include <iostream> #include <cstdlib> #include <algorithm> #include <vector> #include <cstring> #include <queue> #include <stack> #include <functional> #include <set> #include <map> #include <deque> #define WMAX 10000 #define HMAX 10000 //コメントアウトするとdebug()を実行しない #define DEBUG using namespace std; template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } typedef pair<int ,int > P; typedef long long ll; int sx,sy,tx,ty; static const int dx[8] = {0,1,1,1,0,-1,-1,-1}, dy[8] = {1,1,0,-1,-1,-1,0,1}; void solve(){ } void debug(){ } void answer(){ cout << ans << "\n"; } int main(){ cin >> sx >> sy >> tx >> ty; int x = tx-sx,y = ty-sy; for (int i = 0; i < y; ++i) { cout << 'U'; } for (int i = 0; i < x+1; ++i) { cout << 'R'; } for (int i = 0; i < y+1; ++i) { cout << 'D'; } for (int i = 0; i < x+1; ++i) { cout << 'L'; } cout << "UL"; for (int i = 0; i < y+1; ++i) { cout << 'U'; } for (int i = 0; i < x+1; ++i) { cout << 'R'; } cout << 'D'; cout << "\n"; return 0; }
a.cc: In function 'void answer()': a.cc:42:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 42 | cout << ans << "\n"; | ^~~ | abs
s696860933
p03836
C++
#include <cstdio> #include <iostream> #include <cstdlib> #include <algorithm> #include <vector> #include <cstring> #include <queue> #include <stack> #include <functional> #include <set> #include <map> #include <deque> #define WMAX 10000 #define HMAX 10000 //コメントアウトするとdebug()を実行しない #define DEBUG using namespace std; template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } typedef pair<int ,int > P; typedef long long ll; int sx,sy,tx,ty; static const int dx[8] = {0,1,1,1,0,-1,-1,-1}, dy[8] = {1,1,0,-1,-1,-1,0,1}; void solve(){ } void debug(){ } void answer(){ cout << ans << "\n"; } int main(){ cin >> sx >> sy >> tx >> ty; int x = tx-sx,y = ty-sy; for (int i = 0; i < y; ++i) { cout << 'U'; } for (int i = 0; i < x+1; ++i) { cout << 'R'; } for (int i = 0; i < y+1; ++i) { cout << 'D'; } for (int i = 0; i < x+1; ++i) { cout << 'L'; } cout << 'UL'; for (int i = 0; i < y+1; ++i) { cout << 'U'; } for (int i = 0; i < x+1; ++i) { cout << 'R'; } cout << 'D'; cout << "\n"; return 0; }
a.cc:64:17: warning: multi-character character constant [-Wmultichar] 64 | cout << 'UL'; | ^~~~ a.cc: In function 'void answer()': a.cc:42:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 42 | cout << ans << "\n"; | ^~~ | abs
s790779956
p03836
C++
#include <iostream> using namespace std; int sx,sy,tx,ty; int main(){ cin >> sx >> sy >> tx >> ty; for(int y = sy; y < ty; y++){ cout << "U"; } for(int x = sx; x < tx; x++){ cout << "R"; for(int y = ty; y > sy; y--){ cout << "D"; } for(int x = tx; x > sx; x--){ cout << "L"; } cout << "L"; for(int y = sy; y < ty; y++){ cout << "U"; } cout << "U"; for(int x = sx; x < tx; x++){ cout << "R"; } cout << "R"; cout << "D"; cout << "R"; for(int y = ty; y > sy; y--){ cout << "D"; } cout << "D"; for(int x = tx; x > sx; x--){ cout << "L"; } cout << "L"; cout << "U"; return 0; }
a.cc: In function 'int main()': a.cc:48:2: error: expected '}' at end of input 48 | } | ^ a.cc:6:11: note: to match this '{' 6 | int main(){ | ^
s629428643
p03836
C++
#include <bits/stdc++.h> using namespace std; int x1,y1,x2,y2; int main() { while (~scanf("%d%d%d%d",&x1,&y1,&x2,&y2)){ int c1=x2-x1; int c2=y2-y1; for (int i=0;i<c2;++i) printf("U"); for (int i=0;i<c1;++i) printf("R"); for (int i=0;i<c2;++i) printf("D"); for (int i=0;i<c1;++i) printf("L"); printf("L"); for (int i=0;i<=c2;++i) printf("U"); for (int i=0;i<=c1;++i) printf("R"); printf("D"); printf("R"); for (int i=0;i<=c2;++i) printf("D"); for (int i=0;i<=c1;++i) printf("L"); printf("U\n"); } return 0; }
a.cc:4:8: error: 'int y1' redeclared as different kind of entity 4 | int x1,y1,x2,y2; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/cassert:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:9:18: error: invalid operands of types 'int' and 'double(double) noexcept' to binary 'operator-' 9 | int c2=y2-y1; | ~~^~~ | | | | | double(double) noexcept | int
s980478628
p03836
C++
#include <stdio.h> #include <stdlib.h> int map[2001][2001]; struct point { int x; int y; }; struct point target; //functions int equalPoint(struct point p1, struct point p2); struct point intoMap(int x, int y); void rooting(struct point p1, struct point p2, int **map); struct point getFree(int sx, int sy, struct point now_point, int **map); void print_point(struct point p); //------------------------------------------- int main() { int **map = malloc(sizeof(int*)*2001); int sx, sy, tx, ty; scanf("%d%d%d%d", &sx, &sy, &tx, &ty); struct point p1 = intoMap(sx, sy); struct point p2 = intoMap(tx, ty); int i, j; for (i = 0; i < 2001; i++) { map[i] = malloc(sizeof(int)* 2001); for (j=0; j < 2001; j++) { map[i][j] = 0; } } rooting(p1, p2, map); rooting(p2, p1, map); rooting(p1, p2, map); rooting(p2, p1, map); } //---------------------------------------- int equalPoint(struct point p1, struct point p2) { if (p1.x == p2.x) if (p1.y == p2.y) return 1; return 0; } void print_point(struct point p) { printf("---print_point: x:%d, y:%d\n", p.x, p.y); } void rooting(struct point p1, struct point p2, int **map) { target = p2; int i, j ; int sx = p2.x - p1.x; int sy = p2.y - p1.y; struct point now_point = p1; map[p1.x][p1.y] = 1; while (equalPoint(now_point, p2) == 0) { // printf("sx:%d, sy:%d\n", sx, sy); now_point = getFree(sx, sy, now_point, map); sx = p2.x - now_point.x; sy = p2.y - now_point.y; } map[p1.x][p1.y] = 0; map[p2.x][p2.y] = 0; printf("\n"); } struct point intoMap(int x, int y) { struct point ans; ans.x = x + 1000; ans.y = y + 1000; return ans; } struct point getFree(int sx, int sy, struct point now_point, int **map) { int fu, fr, fl, fd; fu = fr = fl = fd = 0; switch(now_point.x) { case 0: fl = -1; break; case 2000: fr = -1; break; } switch(now_point.y) { case 0: fd = -1; break; case 2000: fu = -1; break; } //-------------端っこチェック------------------------------ //右左のチェック if (fl != -1) { if (map[now_point.x-1][now_point.y] == 1) { fl = -1; } } if (fr != -1) { if (map[now_point.x+1][now_point.y] == 1) { fr = -1; } } //上下のチェック if (fu != -1) { if (map[now_point.x][now_point.y+1] == 1) { fu = -1; } } if (fd != -1) { if (map[now_point.x][now_point.y-1] == 1) { fd = -1; } } int box[4]; box[0] = fu; box[1] = fl; box[2] = fd; box[3] = fr; //判定 X軸方向 if (sx != 0) { if (box[2*(sx > 0)+1] == 0) { struct point ret = { .x = now_point.x + ((sx > 0)? 1 : -1), .y = now_point.y, }; map[ret.x][ret.y] = 1; if (sx > 0) { printf("R"); } else { printf("L"); } return ret; } } //判定 Y軸方向 if (sy != 0) { if (box[2*(sy < 0)] == 0) { struct point ret = { .x = now_point.x, .y = now_point.y + ((sy > 0) ? 1 : -1), }; map[ret.x][ret.y] = 1; if (sy > 0) { printf("U"); } else { printf("D"); } return ret; } } int i; for (i = 0; i < 4; i++) { if (box[i] == 0) { if (i % 2 == 0) { struct point ret = { .x = now_point.x, .y = now_point.y + (( i==0 )? 1 : -1), }; map[ret.x][ret.y] = 1; switch(i) { case 0: printf("U"); break; case 1: printf("L"); break; case 2: printf("D"); break; case 3: printf("R"); break; } return ret; } else { struct point ret = { .x = now_point.x + ((i==3) ? 1 : -1), .y = now_point.y , }; map[ret.x][ret.y] = 1; switch(i) { case 0: printf("U"); break; case 1: printf("L"); break; case 2: printf("D"); break; case 3: printf("R"); break; } return ret; } } } printf("last hit\n"); }
a.cc: In function 'int main()': a.cc:20:21: error: invalid conversion from 'void*' to 'int**' [-fpermissive] 20 | int **map = malloc(sizeof(int*)*2001); | ~~~~~~^~~~~~~~~~~~~~~~~~~ | | | void* a.cc:28:20: error: invalid conversion from 'void*' to 'int*' [-fpermissive] 28 | map[i] = malloc(sizeof(int)* 2001); | ~~~~~~^~~~~~~~~~~~~~~~~~~ | | | void* a.cc: In function 'point getFree(int, int, point, int**)': a.cc:202:1: warning: control reaches end of non-void function [-Wreturn-type] 202 | } | ^
s365328966
p03836
C
#include<stdio.h> #include<string.h> int main(){ int sx,sy,tx,ty,x,y,i; char S[4000]; char a[1000] ="R"; char b[1000]="L"; char c[1000]="DRRR"; char d[1000]="ULLL"; scanf("%d %d %d %d",sx,sy,tx,ty); x=tx-sx,y=ty-sy; if(x>=2) { for(i=1;i<=x-1;i++) { strcat(a,"R"); strcat(b,"L"); strcat(c,"R"); strcat(d,"L"); } } strcat(c,"U"); strcat(d,"D"); for(i=1;i<=y;i++) { strcat(a,"U"); strcat(b,"D"); strcat(c,"UU"); strcat(d,"DD"); } strcat(c,"L"); strcat(d,"R"); S=a; //strcat(S,a); strcat(S,b); strcat(S,c); strcat(S,d); printf("%s",s); return 0; }
main.c: In function 'main': main.c:38:10: error: assignment to expression with array type 38 | S=a; | ^ main.c:43:21: error: 's' undeclared (first use in this function) 43 | printf("%s",s); | ^ main.c:43:21: note: each undeclared identifier is reported only once for each function it appears in
s207808463
p03836
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #define dist(u,v) ((abs(u.x-v.x) + abs(u.y-v.y))) #define eql(u,v) (u.x == v.x && v.y == u.y) #define validV(u) (abs(u.x) <= 2000 && abs(u.y) <= 2000) typedef struct _pair{ int x, y, d; }pair; void go(pair orig, pair u, pair dest); int abs(int n) { return (n > 0) ? n : -n; } pair dir[4] = {{0,1,'U'}, {1,0,'R'}, {-1,0,'L'}, {0,-1,'D'}}; int g[2001][2001]; pair s, d; int vis = 0; int c = 0; float euclid(pair u, pair v) { return sqrt((u.x-v.x)*(u.x-v.x) + (u.y-v.y)*(u.y-v.y)); } int main() { scanf("%d %d %d %d",&s.x, &s.y, &d.x, &d.y); int i, j; for ( i = 0; i < 2001 i++) { for ( j=0; j < 2001; j++) { g[i][j] = 0; } } s.x += 1000; s.y += 1000; d.x += 1000; d.y += 1000; int dirX = (d.x-s.x)/abs(d.x-s.x); int dirY = (d.y-s.y)/abs(d.y-s.y); char dy1, dx1, dy2, dx2; dy1 = (dirY>0) ? 'U' : 'D'; dx1 = (dirX>0) ? 'R' : 'L'; dy2 = (dirY>0) ? 'D' : 'U'; dx2 = (dirX>0) ? 'L' : 'R'; int p, q; for (p = s.y; p != d.y; p+=dirY) { g[s.x][p] = 1; printf("%c",dy1); } for (q = s.x; q != d.x; q+=dirX) { g[q][p] = 1; printf("%c",dx1); } for (p = d.y; p != s.y; p-=dirY) { g[d.x][p] = 1; printf("%c",dy2); } for (q = d.x; q != s.x; q-=dirX) { g[q][p] = 1; printf("%c",dx2); } go(s,s,d); printf("\n"); return 0; } void go(pair orig, pair u, pair dest) { pair a[4]; if (eql(dest,u)) { //reached destination go(dest,dest,orig); return; } g[u.x][u.y] = 1; int min = 10000, minI = -1; int i; for (i = 0; i < 4; i++) { a[i].x = u.x + dir[i].x; a[i].y = u.y + dir[i].y; a[i].d = dist(a[i],dest); if (validV(a[i]) && (g[a[i].x][a[i].y] == 0 || eql(dest,a[i]))) { if (a[i].d < min) { min = a[i].d; minI = i; } else if ( a[i].d == min) { //if the current minimum lies on the same line choose the other option if ((a[minI].x - dest.x == 0) || (a[minI].y - dest.y == 0)) { minI = i; } else if ( euclid(a[i],dest) < euclid(a[minI], dest)) { minI = i; } } } } //if we have somewhere to go... if (minI != -1) { printf("%c",dir[minI].d); go(orig, a[minI], dest); } }
main.c: In function 'main': main.c:33:26: error: expected ';' before 'i' 33 | for ( i = 0; i < 2001 i++) { | ^~ | ;
s720130018
p03836
C++
#define SORT(v) sort(v.begin(), v.end()) #include "iostream" #include "map" #include "vector" #include <stack> #include "cstdlib" #include <algorithm> #include <cstdarg> #include "ane.cpp" #define INF (int)1e9 #define NMAX 200 #define MMAX 200 #define MOD 100000 using namespace std; // コメントアウトするとdb_printf()を実行しない #define DEBUG // デバッグ用printf void db_printf(const char* format, ...){ #ifndef DEBUG return; #endif va_list arg; va_start(arg, format); vprintf(format, arg); // コンソールに出力 va_end(arg); } // n次元配列の初期化。第2引数の型のサイズごとに初期化していく。 template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } typedef pair<int, int> P; int N,M,dp[NMAX][MMAX] = {}; int sx,sy,gx,gy; std::vector<char> xmove = {'R', 'L'}, ymove = {'U', 'D'}; static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1}; static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1}; string ans = ""; void solve(){ // 解答アルゴリズム // 往路 for (int i = 0; i < gy-sy; ++i) { ans += ymove[0]; } for (int i = 0; i < gx-sx; ++i) { ans += xmove[0]; } // 復路 for (int i = 0; i < gy-sy; ++i) { ans += ymove[1]; } for (int i = 0; i < gx-sx; ++i) { ans += xmove[1]; } // 往路2 ans += xmove[1]; for (int i = 0; i < gy-sy+1; ++i) { ans += ymove[0]; } for (int i = 0; i < gx-sx+1; ++i) { ans += xmove[0]; } ans += ymove[1]; // 復路2 ans += xmove[0]; for (int i = 0; i < gy-sy+1; ++i) { ans += ymove[1]; } for (int i = 0; i < gx-sx+1; ++i) { ans += xmove[1]; } ans += ymove[0]; } void debug(){ // デバッグ用出力 } void answer(){ // 解答出力 cout << ans << endl; } int main(int argc, char const *argv[]) { // 入力の読み込み,番兵法 ios::sync_with_stdio(false); Fill(dp, -1); cin >> sx >> sy >> gx >> gy; solve(); #ifdef DEBUG debug(); #endif answer(); return 0; }
a.cc:9:10: fatal error: ane.cpp: No such file or directory 9 | #include "ane.cpp" | ^~~~~~~~~ compilation terminated.
s429356801
p03836
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.math.*; public class Main { public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); String[] str = br.readLine().split(" "); int sx = Integer.parseInt(str[0]); int sy = Integer.parseInt(str[1]); int tx = Integer.parseInt(str[2]); int ty = Integer.parseInt(str[3]); int x = tx - sx; int y = ty - sy; StringBuilder sbx = new StringBuilder(); StringBuilder sby = new StringBuilder(); StringBuilder sbx_ = new StringBuilder(); StringBuilder sby_ = new StringBuilder(); for(int i = 0; i < x; i++){ sbx.append('R'); sbx_.append('L'); } for(int i = 0; i < y; i++){ sby.append('U'); sby_.append('D'); } sb.append(sbx.toString()).append(sby.toString()) sb.append(sbx_.toString()).append(sby_.toString()); sb.append('D').append('R').append(sbx.toString()).append(sby.toString()).append('U').append('L'); sb.append('U').append('L').append(sbx_.toString()).append(sby_.toString()).append('D').append('R'); System.out.println(sb); } }
Main.java:34: error: ';' expected sb.append(sbx.toString()).append(sby.toString()) ^ 1 error
s757829013
p03836
C++
はろー
a.cc:1:1: error: '\U0000306f\U0000308d\U000030fc' does not name a type 1 | はろー | ^~~~~~
s127239907
p03836
C
//Date:06-01-17 #include<stdio.h> #include<string.h> #include<assert.h> #include<stdlib.h> #include<stdbool.h> #include<float.h> #include<math.h> #include<ctype.h> #include<limits.h> #include<time.h> #define ll long long #define For(i,n) for(i=0;i<n;i++) #define rep(i ,a ,b) for(i=(a);i<=(b);i++) #define mset(a ,value) memset(a ,value ,sizeof(a)) #define s(a) scanf("%d" ,&a); #define ls(a) scanf("%ld" ,&a) #define reg(i) register int i #define infinite INT_MAX #define MAX 100005 #define NIL -1 int min(int a,int b){ return (a<b?a:b); } int max(int a,int b){ return (a>b?a:b); } main(){ int sx ,sy ,tx ,ty; scanf("%d%d%d%d" ,&sx ,&sy ,&tx ,&ty); int x=sx ,y = sy; while(y!=ty){ printf("U"); y++; } while(x!=tx){ printf("R"); x++; } while(y!=sy){ printf("D"); y--; } while(x!=sx){ printf("L"); x--; } printf("L"); x--; while(y!=(ty+1)){ printf("U"); y++; } while(x!=tx){ printf("R"); x++; } printf("D"); y--; printf("R"); x++; while(y!=(sy-1)){ printf("D"); y--;} while(x!=sx){ printf("L"); x--; } printf("U"); y++; assert((x==sx)&&(y==sy)); return 0; } int k ,s ,x ,y ,z ,c=0; scanf("%d %d" ,&k ,&s); rep(x ,0 ,k) rep(y ,0 ,k){ z = s-(x+y); if(z>=0&&z<=k) c++; } printf("%d" ,c); return 0; }
main.c:25:1: error: return type defaults to 'int' [-Wimplicit-int] 25 | main(){ | ^~~~ main.c:46:15: error: expected declaration specifiers or '...' before string constant 46 | scanf("%d %d" ,&k ,&s); | ^~~~~~~ main.c:46:24: error: expected declaration specifiers or '...' before '&' token 46 | scanf("%d %d" ,&k ,&s); | ^ main.c:46:28: error: expected declaration specifiers or '...' before '&' token 46 | scanf("%d %d" ,&k ,&s); | ^ main.c:15:25: error: expected identifier or '(' before 'for' 15 | #define rep(i ,a ,b) for(i=(a);i<=(b);i++) | ^~~ main.c:47:9: note: in expansion of macro 'rep' 47 | rep(x ,0 ,k) | ^~~ main.c:15:36: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<=' token 15 | #define rep(i ,a ,b) for(i=(a);i<=(b);i++) | ^~ main.c:47:9: note: in expansion of macro 'rep' 47 | rep(x ,0 ,k) | ^~~ main.c:15:43: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 15 | #define rep(i ,a ,b) for(i=(a);i<=(b);i++) | ^~ main.c:47:9: note: in expansion of macro 'rep' 47 | rep(x ,0 ,k) | ^~~ main.c:15:36: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<=' token 15 | #define rep(i ,a ,b) for(i=(a);i<=(b);i++) | ^~ main.c:48:17: note: in expansion of macro 'rep' 48 | rep(y ,0 ,k){ | ^~~ main.c:15:43: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 15 | #define rep(i ,a ,b) for(i=(a);i<=(b);i++) | ^~ main.c:48:17: note: in expansion of macro 'rep' 48 | rep(y ,0 ,k){ | ^~~ main.c:52:16: error: expected declaration specifiers or '...' before string constant 52 | printf("%d" ,c); | ^~~~ main.c:52:22: error: expected declaration specifiers or '...' before 'c' 52 | printf("%d" ,c); | ^ main.c:53:9: error: expected identifier or '(' before 'return' 53 | return 0; | ^~~~~~ main.c:54:1: error: expected identifier or '(' before '}' token 54 | } | ^
s763801879
p03836
C++
#include <bits/stdc++.h> using namespace std; int main(){ int sx,sy,tx,ty,i; cin>>sx>>sy>>tx>>ty; xsa=tx-sx; ysa=ty-sy; for(i=0; i<ysa; i++){ cout<<'U'; } for(i=0;i<xsa; i++){ cout<<'R'; } for(i=0; i<ysa; i++){ cout<<'D'; } for(i=0; i<=xsa; i++){ cout<<'L'; } for(i=0; i<=ysa; i++){ cout<<'U'; } for(i=0; i<=xsa; i++){ cout<<'R'; } cout<<"DR"; for(i=0; i<=ysa; i++){ cout<<'D'; } for(i=0; i<=xsa; i++){ cout<<'L'; } cout'U'; }
a.cc: In function 'int main()': a.cc:6:3: error: 'xsa' was not declared in this scope 6 | xsa=tx-sx; | ^~~ a.cc:7:3: error: 'ysa' was not declared in this scope 7 | ysa=ty-sy; | ^~~ a.cc:33:7: error: expected ';' before 'U' 33 | cout'U'; | ^~~ | ;
s779285165
p03836
C
#include <stdio.h> #define printCN(c, n) { while(n>0){ putchar(c); n--; } } int main() { int sx, sy, tx, ty; scanf("%d%d%d%d", &sx, &sy, &tx, &ty); printCN('U', ty-sy); printCN('R', tx-sx); printCN('D', ty-sy); printCN('L', tx-sx); putchar('L'); printCN('U', ty-sy+1); printCN('R', tx-sx+1); putchar('D'); putchar('R'); printCN('D', ty-sy+1); printCN('L', tx-sx+1); putchar('U'); return 0; }
main.c: In function 'main': main.c:3:50: error: lvalue required as decrement operand 3 | #define printCN(c, n) { while(n>0){ putchar(c); n--; } } | ^~ main.c:16:2: note: in expansion of macro 'printCN' 16 | printCN('U', ty-sy+1); | ^~~~~~~ main.c:3:50: error: lvalue required as decrement operand 3 | #define printCN(c, n) { while(n>0){ putchar(c); n--; } } | ^~ main.c:17:2: note: in expansion of macro 'printCN' 17 | printCN('R', tx-sx+1); | ^~~~~~~ main.c:3:50: error: lvalue required as decrement operand 3 | #define printCN(c, n) { while(n>0){ putchar(c); n--; } } | ^~ main.c:20:2: note: in expansion of macro 'printCN' 20 | printCN('D', ty-sy+1); | ^~~~~~~ main.c:3:50: error: lvalue required as decrement operand 3 | #define printCN(c, n) { while(n>0){ putchar(c); n--; } } | ^~ main.c:21:2: note: in expansion of macro 'printCN' 21 | printCN('L', tx-sx+1); | ^~~~~~~
s320965318
p03836
C++
#include <bits/stdc++.h> using namespace std; const int N = 0; pair < int , int > start; pair < int , int > end; int vis[2017][2017]; int dr[4] = { 1 , 0 , -1 , 0 }; int dc[4] = { 0 , 1 , 0 , -1 }; int flag = 0; string one,two,three,four; int bfs() { queue < pair < pair < int , int > , string > > q; q.push(make_pair(start,"")); while(!q.empty()) { pair < pair < int , int > , string > u = q.front(); q.pop(); if(u.first==end) { if(flag==0) { one = u.second; flag++; return 0; } if(flag==1) { two = u.second; flag++; return 0; } if(flag==2) { three = u.second; flag++; return 0; } if(flag==3) { four = u.second; return 0; } } if(u.first!=start && u.first!=end) { vis[u.first.first][u.first.second] = 1; } for(int i=0;i<4;i++) { if(u.first.first + dc[i] >=0 && u.first.first + dc[i] <= 2000 && u.first.second + dr[i] >=0 && u.first.second + dr[i] <=2000 && vis[u.first.first + dc[i]][u.first.second + dr[i]]==0) { if(i==0) q.push(make_pair(make_pair(u.first.first + dc[i] , u.first.second + dr[i]) , u.second + "U")); if(i==1) q.push(make_pair(make_pair(u.first.first + dc[i] , u.first.second + dr[i]) , u.second + "R")); if(i==2) q.push(make_pair(make_pair(u.first.first + dc[i] , u.first.second + dr[i]) , u.second + "D")); if(i==3) q.push(make_pair(make_pair(u.first.first + dc[i] , u.first.second + dr[i]) , u.second + "L")); } } } } int main() { int x,y; cin >> x >> y; x+=1000; y+=1000; start = make_pair(x,y); cin >> x >> y; x+=1000; y+=1000; end = make_pair(x,y); bfs(); memset(vis,0,sizeof(vis)); pair < int , int > now = start; for(int i=0;i<one.size();i++) { if(now!= start && now!=end) vis[now.first][now.second]++; if(one[i]=='U') now.second++; if(one[i]=='D') now.second--; if(one[i]=='L') now.first--; if(one[i]=='R') now.first++; } bfs(); memset(vis,0,sizeof(vis)); now = start; for(int i=0;i<two.size();i++) { if(now!= start && now!=end) vis[now.first][now.second]++; if(two[i]=='U') now.second++; if(two[i]=='D') now.second--; if(two[i]=='L') now.first--; if(two[i]=='R') now.first++; } now = start; for(int i=0;i<one.size();i++) { if(now!= start && now!=end) vis[now.first][now.second]++; if(one[i]=='U') now.second++; if(one[i]=='D') now.second--; if(one[i]=='L') now.first--; if(one[i]=='R') now.first++; } bfs(); memset(vis,0,sizeof(vis)); now = start; for(int i=0;i<one.size();i++) { if(now!= start && now!=end) vis[now.first][now.second]++; if(three[i]=='U') now.second++; if(three[i]=='D') now.second--; if(three[i]=='L') now.first--; if(three[i]=='R') now.first++; } now = start; for(int i=0;i<two.size();i++) { if(now!= start && now!=end) vis[now.first][now.second]++; if(two[i]=='U') now.second++; if(two[i]=='D') now.second--; if(two[i]=='L') now.first--; if(two[i]=='R') now.first++; } now = start; for(int i=0;i<one.size();i++) { if(now!= start && now!=end) vis[now.first][now.second]++; if(one[i]=='U') now.second++; if(one[i]=='D') now.second--; if(one[i]=='L') now.first--; if(one[i]=='R') now.first++; } bfs(); reverse(two.begin(),two.end()); reverse(four.begin(),four.end()); for(int i=0;i<two.size();i++) { if(two[i]=='U') two[i] = 'D'; else if(two[i]=='D') two[i] = 'U'; else if(two[i]=='R') two[i] = 'L'; else if(two[i]=='L') two[i] = 'R'; } for(int i=0;i<four.size();i++) { if(four[i]=='U') four[i] = 'D'; else if(four[i]=='D') four[i] = 'U'; else if(four[i]=='R') four[i] = 'L'; else if(four[i]=='L') four[i] = 'R'; } cout << one << two << three << four; }
a.cc: In function 'int bfs()': a.cc:22:29: error: reference to 'end' is ambiguous 22 | if(u.first==end) | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166, from a.cc:1: /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ 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: /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/algorithmfwd.h:39, from /usr/include/c++/14/bits/stl_algo.h:59, from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:7:20: note: 'std::pair<int, int> end' 7 | pair < int , int > end; | ^~~ a.cc:48:47: error: reference to 'end' is ambiguous 48 | if(u.first!=start && u.first!=end) | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:7:20: note: 'std::pair<int, int> end' 7 | pair < int , int > end; | ^~~ a.cc: In function 'int main()': a.cc:78:9: error: reference to 'end' is ambiguous 78 | end = make_pair(x,y); | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:7:20: note: 'std::pair<int, int> end' 7 | pair < int , int > end; | ^~~ a.cc:84:40: error: reference to 'end' is ambiguous 84 | if(now!= start && now!=end) vis[now.first][now.second]++; | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:7:20: note: 'std::pair<int, int> end' 7 | pair < int , int > end; | ^~~ a.cc:95:40: error: reference to 'end' is ambiguous 95 | if(now!= start && now!=end) vis[now.first][now.second]++; | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:7:20: note: 'std::pair<int, int> end' 7 | pair < int , int > end; | ^~~ a.cc:104:40: error: reference to 'end' is ambiguous 104 | if(now!= start && now!=end) vis[now.first][now.second]++; | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:7:20: note: 'std::pair<int, int> end' 7 | pair < int , int > end; | ^~~ a.cc:115:40: error: reference to 'end' is ambiguous 115 | if(now!= start && now!=end) vis[now.first][now.second]++; | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^
s992637284
p03836
C
#include<stdio.h> int main(){ int x,y,sx,sy,tx,ty,i; scanf("%d %d %d %d",&sx,&xy,&tx,&ty); x=tx-sx; y=ty-sy; for(i=0;i<x;i++) printf("U"); for(i=0;i<y;i++) printf("R"); for(i=0;i<x;i++) printf("D"); for(i=0;i<=y;i++) printf("L"); for(i=0;i<=x;i++) printf("U"); for(i=0;i<=y;i++) printf("R"); printf("DR"); for(i=0;i<=x;i++) printf("D"); for(i=0;i<=y;i++) printf("L"); printf("U\n"); return 0; }
main.c: In function 'main': main.c:5:34: error: 'xy' undeclared (first use in this function); did you mean 'ty'? 5 | scanf("%d %d %d %d",&sx,&xy,&tx,&ty); | ^~ | ty main.c:5:34: note: each undeclared identifier is reported only once for each function it appears in
s587393872
p03836
Java
public class Main { public static void main(String[] args) { int sx, sy, tx, ty; Scanner s = new Scanner(System.in); sx = s.nextInt(); sy = s.nextInt(); tx = s.nextInt(); ty = s.nextInt(); int i; for (i = 0; i < ty - sy; i++) { System.out.print("U"); } for (i = 0; i < tx - sx; i++) { System.out.print("R"); } for (i = 0; i < ty - sy; i++) { System.out.print("D"); } for (i = 0; i < tx - sx; i++) { System.out.print("L"); } System.out.print("L"); for (i = 0; i <= ty - sy; i++) { System.out.print("U"); } for (i = 0; i <= tx - sx; i++) { System.out.print("R"); } System.out.print("DR"); for (i = 0; i <= ty - sy; i++) { System.out.print("D"); } for (i = 0; i <= tx - sx; i++) { System.out.print("L"); } System.out.print("U"); } }
Main.java:5: error: cannot find symbol Scanner s = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:5: error: cannot find symbol Scanner s = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s420367235
p03836
C
$/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U
main.c:1:2: error: expected '=', ',', ';', 'asm' or '__attribute__' before '/=' token 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^~ main.c:1:8: warning: data definition has no type or storage class 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^ main.c:1:8: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int] main.c:1:10: error: type defaults to 'int' in declaration of 'b' [-Wimplicit-int] 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^ main.c:1:12: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^ main.c:1:14: error: type defaults to 'int' in declaration of 'd' [-Wimplicit-int] 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^ main.c:1:16: error: '$' undeclared here (not in a function) 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^ main.c:1:18: error: expected expression before '.' token 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^ main.c:1:30: warning: data definition has no type or storage class 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^ main.c:1:30: error: type defaults to 'int' in declaration of 'x' [-Wimplicit-int] main.c:1:32: error: initializer element is not constant 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^ main.c:1:36: warning: data definition has no type or storage class 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^ main.c:1:36: error: type defaults to 'int' in declaration of 'y' [-Wimplicit-int] main.c:1:38: error: initializer element is not constant 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^ main.c:1:47: error: expected '=', ',', ';', 'asm' or '__attribute__' before '?' token 1 | $/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U | ^
s806166844
p03836
C++
#include <iostream> #include <iomanip> #include <string> #include <vector> #include <queue> #include <algorithm> #include <utility> #include <cmath> #include <bitset> #include <map> #define INF_LL 9000000000000000000 #define INF 2000000000 #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) using namespace std; typedef long long ll; typedef pair<int, int> PII; class Union_find{ private: vector<int> par; vector<int> rank; int n; public: Union_find(int a){ n = a; for(int i = 0;i < n;i++){ par.push_back(i); rank.push_back(0); } } int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } } void unite(int x, int y){ x = find(x); y = find(y); if(x == y) return; if(rank[x] < rank[y]){ par[x] = y; }else{ par[y] = x; if(rank[x] == rank[y]) rank[x]++; } } bool same(int x, int y){ return find(x) == find(y); } }; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; bool visited[2020][2020]; int main(){ int sx, sy, tx, ty; memset(visited, 0, sizeof visited); cin >> sx >> sy >> tx >> ty; REP(i, abs(tx-sx)){ if(tx > sx) cout << "R"; else cout << "L"; } REP(i, abs(ty-sy)){ if(ty > sy) cout << "U"; else cout << "D"; } REP(i, abs(tx-sx)){ if(tx > sx) cout << "L"; else cout << "R"; } REP(i, abs(ty-sy)){ if(ty > sy) cout << "D"; else cout << "U"; } if(tx > sx) cout << "L"; else cout << "R"; REP(i, abs(ty-sy)+1){ if(ty > sy) cout << "U"; else cout << "D"; } REP(i, abs(tx-sx)+1){ if(tx > sx) cout << "R"; else cout << "L"; } if(ty > sy) cout << "D"; else cout << "U"; if(tx > sx) cout << "R"; else cout << "L"; REP(i, abs(ty-sy)+1){ if(ty > sy) cout << "D"; else cout << "U"; } REP(i, abs(tx-sx)+1){ if(tx > sx) cout << "L"; else cout << "R"; } if(ty > sy) cout << "U"; else cout << "D"; cout << endl; }
a.cc: In function 'int main()': a.cc:69:9: error: 'memset' was not declared in this scope 69 | memset(visited, 0, sizeof visited); | ^~~~~~ a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 10 | #include <map> +++ |+#include <cstring> 11 |
s494775905
p03837
C++
#include <bits/stdc++.h> using namespace std; #define ll long long #define se second #define fi first #define mp make_pair #define pb push_back #define ll long long const int MAXN = (int)1e7 + 1000; const int N = 105; const int mod = (int)1e9 + 7; const int INF = (int)1e9; int d[N][N]; struct edge{ int u,v,c; }; edge e[N]; bool ok(int number, int v1,int v2){ return (d[v1][e[number].u] + d[e[number].v][v2] + e[number].c == d[v1][v2]); } int main(){ // ifstream cin("input.txt"); // ofstream cout("output.txt"); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; cin >> n >> m; for(int i = 0;i <= 101;i++){ for(int j = 0;j <= 101;j++){ d[i][j] = INF; } } int ans = 0; for(int i = 1;i <= m;i++){ cin >> e[i].u >> e[i].v >> e[i].c; if(d[e[i].u][e[i].v] > e[i].c){ d[e[i].u][e[i].v] = e[i].c; d[e[i].v][e[i].u] = e[i].c; } } for(int i = 1;i <= m;i++){ if(e[i].c != d[e[i].u][e[i].v]){ e[i] = INF; } } for(int i = 1;i <= n;i++)d[i][i] = 0; for(int k = 1;k <= n;k++){ for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++){ d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } for(int i = 1;i <= m;i++){ if(e[i].u == e[i].v || e[i].c == INF){ ans++; continue; } bool need = 0; for(int j = 1;j <= n;j++){ for(int k = 1;k <= n;k++){ if(ok(i, j, k) || ok(i, k, j)){ need = 1; break; } } } ans += (!need); } cout << ans; return 0; }
a.cc: In function 'int main()': a.cc:44:20: error: no match for 'operator=' (operand types are 'edge' and 'const int') 44 | e[i] = INF; | ^~~ a.cc:14:8: note: candidate: 'constexpr edge& edge::operator=(const edge&)' 14 | struct edge{ | ^~~~ a.cc:14:8: note: no known conversion for argument 1 from 'const int' to 'const edge&' a.cc:14:8: note: candidate: 'constexpr edge& edge::operator=(edge&&)' a.cc:14:8: note: no known conversion for argument 1 from 'const int' to 'edge&&'
s862777445
p03837
C++
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define ll long long #define ld long double #define rep(i, n) for(ll i = 0; i < n; ++i) #define rep2(i, a, b) for(ll i = a; i <= b; ++i) #define rrep(i, a, b) for(ll i = a; i >= b; --i) #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define pb push_back #define eb emplace_back #define vi vector<int> #define vll vector<ll> #define vpi vector<pii> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define endl '\n' using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } const int MOD=1e9+7; const ll INF=1e18; const double PI=acos(-1); int dx[8] = {1,0,-1,0,1,1,-1,-1}; int dy[8] = {0,1,0,-1,-1,1,1,-1}; const int MAX=510000; int dist[110][110]; int pre[110][110]; int use[110][110]; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; rep(i,n)rep(j,n){ dist[i][j]=MOD; pre[i][j]=i; } vector<int>a(n),b(n),c(n); rep(i,m){ cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--; dist[a[i]][b[i]]=c; dist[b[i]][a[i]]=c; use[a[i]][b[i]]++; use[b[i]][a[i]]++; } rep(k,n)rep(i,n)rep(j,n){ chmin(dist[i][j],dist[i][k]+dist[k][j]); } int ans = m; rep(i,m){ bool ok = false; rep(j,n) if(dist[j][a[i]]+c[i] == dist[j][b[i]]) ok = true; if(ok)ans--; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:65:22: error: cannot convert 'std::vector<int>' to 'int' in assignment 65 | dist[a[i]][b[i]]=c; | ^ | | | std::vector<int> a.cc:66:22: error: cannot convert 'std::vector<int>' to 'int' in assignment 66 | dist[b[i]][a[i]]=c; | ^ | | | std::vector<int>
s467744565
p03837
C++
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define ll long long #define ld long double #define rep(i, n) for(ll i = 0; i < n; ++i) #define rep2(i, a, b) for(ll i = a; i <= b; ++i) #define rrep(i, a, b) for(ll i = a; i >= b; --i) #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define pb push_back #define eb emplace_back #define vi vector<int> #define vll vector<ll> #define vpi vector<pii> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define endl '\n' using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } const int MOD=1e9+7; const ll INF=1e18; const double PI=acos(-1); int dx[8] = {1,0,-1,0,1,1,-1,-1}; int dy[8] = {0,1,0,-1,-1,1,1,-1}; const int MAX=510000; int dist[110][110]; int pre[110][110]; int use[110][110]; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; rep(i,n)rep(j,n){ dist[i][j]=MOD; pre[i][j]=i; } vector<int>a(n),b(n),c(n); while(m--){ cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--; dist[a[i]][b[i]]=c; dist[b[i]][a[i]]=c; use[a[i]][b[i]]++; use[b[i]][a[i]]++; } rep(k,n)rep(i,n)rep(j,n){ chmin(dist[i][j],dist[i][k]+dist[k][j]); } int ans = m; rep(i,m){ bool ok = false; rep(j,n) if(dist[j][a[i]]+c[i] == dist[j][b[i]]) ok = true; if(ok)ans--; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:61:14: error: 'i' was not declared in this scope 61 | cin >> a[i] >> b[i] >> c[i]; | ^
s942034081
p03837
C++
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> ii; #define DEBUG freopen("in.txt", "r", stdin); struct fastio { fastio() { ios::sync_with_stdio(false); cout << setprecision(10) << fixed; cin.tie(0); } }; fastio _fast_io; const int N = 105; int n, m, ans, a, b, c; vector<int> M[2010]; // at most 2000 edges bool good[1010]; vector<int> e[N]; int dist[N]; auto cmp = [&](int a, int b){ int f1 = M[a][0], w1 = M[a][2]; int f2 = M[b][0], w2 = M[b][2]; int aa = dist[f1] + w1; int bb = dist[f2] + w2; return aa >= bb; }; void run(int x) { memset(dist, 0x3f, N); priority_queue<int, vector<int>, decltype(cmp)> que(cmp); dist[x] = 0; for (auto z : e[x]) { que.push(z); } while (!que.empty()) { int y = que.top(); que.pop(); int f = M[y][0], t = M[y][1], w = M[y][2]; int ndist = dist[f] + w; if (dist[t] > ndist) { dist[t] = ndist; good[y % m] = true; for (int z : e[t]) { que.push(z); } } else if (dist[t] == ndist) { good[y % m] = true; } } } int main() { cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> a >> b >> c; M[i] = {a, b, c}; M[m + i] = {b, a, c}; e[a].push_back(i); e[b].push_back(i + m); } for (int i = 1; i <= n; ++i) { run(i); } for (int i = 0; i < m; ++i) { if (good[i]) ++ans; } cout << m - ans << endl; return 0; }
a.cc:25:13: error: non-local lambda expression cannot have a capture-default 25 | auto cmp = [&](int a, int b){ | ^
s195226420
p03837
C++
#include <iostream> #include <string> #include <cstring> #include <stack> #include <queue> #include <cctype> #include <algorithm> #include <vector> #include <map> #include <set> #include <cmath> #include <stdlib.h> #include <tuple> #include <iomanip> #include <iterator> #include <stdio.h> #include <fstream> #include <time.h> #include <bit> #include <bitset> #include <cstdint> using namespace std; const double PI = 3.14159265358979323846; const long long int MOD = 1000000000 + 7; struct UnionFind { vector<int> parent; UnionFind(int N) : parent(N) { for (int i = 0; i < N; i++) { parent[i] = -1; } } int root(int i) { if (parent[i] < 0) { return i; } return (parent[i] = root(parent[i])); } bool unite(int from, int to) { int rx = root(from); int ry = root(to); if (rx != ry) { parent[ry] += parent[rx]; parent[rx] = ry; return true; } else { return false; } } bool same(int x, int y) { return root(x) == root(y); } int treeSize(int x) { return -parent[root(x)]; } }; long long int modpow(long long int base, long long int pow, long long int mod) { if (pow == 1) { return base; } else if (pow == 0) { return 1; } if (pow % 2 == 0) { auto temp = modpow(base, pow / 2, mod); return (temp * temp) % mod; } else { return (base * modpow(base, pow - 1, mod)) % mod; } } long long int moddiv(long long int X, long long int Y, long long int mod) { auto fermatDiv = modpow(Y, mod - 2, mod); return (X * fermatDiv) % mod; } long long modCombination(long long left, long long right, long long int mod) { long long answer = 1; if (left > right) { for (long long i = 0; i < right; i++) { answer = (answer * (left - i)) % mod; answer = moddiv(answer, (i + 1), mod); } } return answer; } bool IsPrime(long long N) { if (N == 1) { return false; } for (long long i = 2; i * i <= N; i++) { if (N % i == 0) { return false; } } return true; } vector<pair<long long, long long> > prime_factorize(long long N) { vector<pair<long long, long long> > res; for (long long a = 2; a * a <= N; ++a) { if (N % a != 0) continue; long long ex = 0; // 指数 // 割れる限り割り続ける while (N % a == 0) { ++ex; N /= a; } // その結果を push res.push_back({ a, ex }); } // 最後に残った数について if (N != 1) res.push_back({ N, 1 }); return res; } map<long long, set<long long>> cache; set<long long> enum_divisors(long long N) { set<long long> res; for (long long i = 1; i * i <= N; ++i) { if (N % i == 0) { res.insert(i); if (cache.count(N / i) > 0) { auto copy = cache[N / i]; auto copy2 = cache[N / i]; for (auto v : res) { if (v != 1) { //cout << "v*" << v << endl; for (auto itr = copy2.begin(); itr != copy2.end(); itr++) { copy.insert(*itr * v); } break; } } cache[N] = copy; return copy; } // 重複しないならば i の相方である N/i も push if (N / i != i) res.insert(N / i); } } cache[N] = res; return res; } long long euclid(long long a, long long b) { if (a > b) { long long temp = b; b = a; a = temp; } if (b % a == 0) { return a; } else { return euclid(a, b - a); } } long long gcd(long long a, long long b) { if (b > a) { long long temp = b; b = a; a = temp; } //cout << "a:" << a << "b:" << b << endl; long long c = a % b; if (c == 0) { return b; } else { return gcd(b, c); } } struct Edge { int to; int cost; public:Edge(int _to, int _cost) { to = _to; cost = _cost; } }; int main() { int N, M; cin >> N >> M; vector<vector<Edge>> edges(N + 1, vector<Edge>()); for (int i = 0; i < M; i++) { int a, b, c; cin >> a >> b >> c; /*int from = min(a, b); int to = max(a, b); edges[from].emplace_back(to, c);*/ edges[a].emplace_back(b, c); edges[b].emplace_back(a, c); } vector<vector<int>> d(N + 1, vector<int>(N + 1)); for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { d[i][j] = INT_MAX; if (i == j) { d[i][j] = 0; } } } int answer = 0; for (int s = 1; s <= N; s++) { priority_queue <pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q; q.emplace(0, s); while (!q.empty()) { auto pair = q.top(); q.pop(); int v = pair.second; if (d[s][v] < pair.first) { continue; } for (auto e : edges[v]) { if (d[s][e.to] > d[s][v] + e.cost) { d[s][e.to] = d[s][v] + e.cost; q.emplace(d[s][e.to], e.to); } } } for (auto e : edges[s]) { //cout << s << ":" << e.to << ":" << d[s][e.to] << endl; if (e.cost > d[s][e.to]) { answer++; } } } cout << answer / 2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:230:23: error: 'INT_MAX' was not declared in this scope 230 | d[i][j] = INT_MAX; | ^~~~~~~ a.cc:22:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 21 | #include <cstdint> +++ |+#include <climits> 22 | using namespace std;
s460489264
p03837
C++
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define MOD 998244353 template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;} template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;} const long long INF = 1LL << 60; bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){ return firstElof.first < secondElof.first; } bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){ return firstElof.second < secondElof.second; } //四方向への移動ベクトル const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; struct edge{//グラフに使うヤツ ll from,to,cost; }; typedef vector<vector<edge> > G; ll gcd(ll a,ll b){ if (a%b==0)return(b); else return(gcd(b,a%b)); } ll n,m; vector<vector<edge> > graph; ll cost[105][105]; bool used[105][105]; void warshall_floyd(){ for (ll i=0;i<n;i++){ for (ll j=0;j<n;j++){ for (ll k=0;k<n;k++){ if (cost[i][j]>cost[i][k]+cost[k][j]){ cost[i][j]=cost[i][k]+cost[k][j]; } } } } } vector<edge> dist; int main() { ll n,m; cin >> n >> m; graph=G(n); for (ll i=0;i<n;i++){ for (ll j=0;j<n;j++){ if (i==j){ cost[i][j]=0; }else{ cost[i][j]=INF; } } } for (ll i=0;i<m;i++){ ll a,b,c; cin >> a >> b >> c; a--; b--; cost[a][b]=c; cost[b][a]=c; edge e; e.from=a; e.to=b; e.cost=c; dist.push_back(e); e.from=b; e.to=a; e.cost=c; dist.push_back(e); } warshall_floyd(); ll ans=0; for (ll i=0;i<dist.size();i++){ bool flag=false; for (ll j=0;j<n;j++){ for (ll k=0;k<n;k++){ if (cost[j][dist[i].from]+dist[i].cost+cost[dist[i].to][j]==dist[i][j]){ flag=true; } } } if (!flag){ ans++; } } cout << ans/2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:82:84: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<edge>, edge>::value_type' {aka 'edge'} and 'll' {aka 'long long int'}) 82 | if (cost[j][dist[i].from]+dist[i].cost+cost[dist[i].to][j]==dist[i][j]){ | ^
s549972919
p03837
C++
/*input 3 3 1 2 1 1 3 1 2 3 3 */ #include <bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<ld,ld> pdd; #define IOS ios_base::sync_with_stdio(0); cin.tie(0) #define ALL(a) a.begin(),a.end() #define SZ(a) ((int)a.size()) #define F first #define S second #define REP(i,n) for(int i=0;i<((int)n);i++) #define eb emplace_back #define pb push_back #define MP(a,b) make_pair(a,b) #define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end())))) #define GET_POS(c,x) (int)(lower_bound(c.begin(),c.end(),x)-c.begin()) #define EL cout<<'\n' #define BS(a,x) binary_search(ALL(a),x) template<typename T1,typename T2> ostream& operator<<(ostream& out,pair<T1,T2> P){ out<<'('<<P.F<<','<<P.S<<')'; return out; } template<typename T> ostream& operator<<(ostream& out,vector<T> V){ REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":""); return out; } //}}} const ll maxn=300005; const ll maxlg=20; const ll INF64=1e18; const int INF=0x3f3f3f3f; const ll MOD=ll(1e9+7); const ld PI=acos(-1); const ld eps=1e-9; //const ll p=880301; //const ll P=31; ll mypow(ll a,ll b){ ll res=1LL; while(b){ if(b&1) res=res*a%MOD; a=a*a%MOD; b>>=1; } return res; } int dis[maxn][maxn]; vector<pair<pii,int>> edge; int main(){ IOS; int n,m; cin>>n>>m; REP(i,n) REP(j,n){ dis[i][j]=(i==j)?0:INF; } REP(i,m){ int u,v,d; cin>>u>>v>>d; u--;v--; edge.eb(MP(u,v),d); dis[u][v]=dis[v][u]=d; } REP(j,n) REP(i,n) REP(k,n){ dis[i][k]=min(dis[i][k],dis[i][j]+dis[j][k]); } // REP(i,n) REP(j,n) cout<<dis[i][j]<<" \n"[j==n-1]; int cnt=0; for(auto i:edge){ if(dis[i.F.F][i.F.S]!=i.S) cnt++; } cout<<cnt<<'\n'; return 0; }
/tmp/ccJuXzPg.o: in function `main': a.cc:(.text+0x1f7): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJuXzPg.o a.cc:(.text+0x398): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJuXzPg.o /tmp/ccJuXzPg.o: in function `__static_initialization_and_destruction_0()': a.cc:(.text+0x45f): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJuXzPg.o a.cc:(.text+0x478): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJuXzPg.o collect2: error: ld returned 1 exit status
s342017529
p03837
C++
#include <bits/stdc++.h> #include <type_traits> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define ddrep(i, n) for (int i = n; i > 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define ssrep(i, s, t) for (int i = s; i <= t; ++i) #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() #define pb push_back #define eb emplace_back #define fi first #define se second #define chmax(x, y) (x = max(x, y)) #define chmin(x, y) (x = min(x, y)) using pi = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vs = vector<string>; using vvs = vector<vs>; using ld = long double; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; rep(i, (int)v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } template <typename T, size_t S> void printArray(const T (&array)[S]) { for (auto val : array) std::cout << val << ", "; std::cout << "\n"; } const int mod = 1e9 + 7; const int inf = 1e9 + 5; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << std::setprecision(10); int n, m; std::cin >> n >> m; vvi to(n, vi(n, inf)), cost; rep(i, n) to[i][i] = 0; rep(i, m) { int a, b, c; std::cin >> a >> b >> c; --a, --b; to[a][b] = to[b][a] = c; } cost = to; rep(k, n) rep(i, n) rep(j, n) chmin(cost[i][j], cost[i][k] + cost[k][j]); set<pi> walked; rep(i, n) rep(j, n) { int s = i, g = j, cur = i; while (cur != g) { rep(k, n) { if (k == cur || to[cur][k]+cost[k][g] != cost[cur][g]) continue; walked.insert(cur, k); cur = k; break; } } } std::cout << m-(int)walked.size()/2 << "\n"; }
In file included from /usr/include/c++/14/set:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158, from a.cc:1: /usr/include/c++/14/bits/stl_set.h: In instantiation of 'void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]': a.cc:81:30: required from here 81 | walked.insert(cur, k); | ~~~~~~~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/stl_set.h:569:38: error: no matching function for call to 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::_M_insert_range_unique(int&, int&)' 569 | { _M_t._M_insert_range_unique(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/map:62, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152: /usr/include/c++/14/bits/stl_tree.h:1096:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value)> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _Key = std::pair<int, int>; _Val = std::pair<int, int>; _KeyOfValue = std::_Identity<std::pair<int, int> >; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 1096 | _M_insert_range_unique(_InputIterator __first, _InputIterator __last) | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1096:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<std::pair<int, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value), void> std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = int]': /usr/include/c++/14/bits/stl_set.h:569:31: required from 'void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 569 | { _M_t._M_insert_range_unique(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ a.cc:81:30: required from here 81 | walked.insert(cur, k); | ~~~~~~~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1095:58: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 1095 | __enable_if_t<__same_value_type<_InputIterator>::value> | ^~~~~ /usr/include/c++/14/bits/stl_set.h: In instantiation of 'void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]': a.cc:81:30: required from here 81 | walked.insert(cur, k); | ~~~~~~~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1105:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value))> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _Key = std::pair<int, int>; _Val = std::pair<int, int>; _KeyOfValue = std::_Identity<std::pair<int, int> >; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 1105 | _M_insert_range_unique(_InputIterator __first, _InputIterator __last) | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1105:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<std::pair<int, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value)), void> std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = int]': /usr/include/c++/14/bits/stl_set.h:569:31: required from 'void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 569 | { _M_t._M_insert_range_unique(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ a.cc:81:30: required from here 81 | walked.insert(cur, k); | ~~~~~~~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1104:59: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 1104 | __enable_if_t<!__same_value_type<_InputIterator>::value> | ^~~~~
s509089119
p03837
C++
#include<cstdio> #include<algorithm> int g[101][101],a[1000],b[1000],c[1000]; int const infty=10000000; int main(){ int n,m,answer=0; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ g[i][j]=infty; } } for(int i=0;i<m;i++){ // コピペでfastest取ったら嫌なので cin >> a[i] >> b[i] >> c[i]; g[a[i]][b[i]]=g[b[i]][a[i]]=c[i]; } for(int k=1;k<=n;k++){ for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ g[i][j]=std::min(g[i][k]+g[k][j],g[i][j]); } } } for(int i=0;i<m;i++){ bool use=false; for(int j=1;j<=n;j++){ if(j==a[i]||j==b[i]){ if(c[i]==g[a[i]][b[i]])use=true; // }else if(g[a[i]][j]==c[i]+g[b[i]][j])use=true; } } if(!use)answer++; } printf("%d",answer); return 0; }
a.cc: In function 'int main()': a.cc:15:3: error: 'cin' was not declared in this scope 15 | cin >> a[i] >> b[i] >> c[i]; | ^~~
s238033669
p03837
C++
2
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 2 | ^
s654439429
p03837
C++
#define int long long using namespace std; const int MOD = 1000000007; const int INF = 1e15; using Graph = vector<vector<int>>; signed main(){ int N, M; cin >> N >> M; vector<vector<int>> G(N, vector<int>(N, INF)); vector<pair<int, int>> E(M); for( int i = 0; i < N; i++ ) G.at(i).at(i) = 0; for( int i = 0; i < M; i++ ){ int A, B, C; cin >> A >> B >> C; A--; B--; G.at(A).at(B) = C; G.at(B).at(A) = C; E.at(i) = {A, B}; } vector<bool> fg(M, true); for (int k = 0; k < N; k++){ // 経由する頂点 for (int i = 0; i < N; i++) { // 始点 for (int j = 0; j < N; j++) { // 終点 if( G[i][j] > G[i][k] + G[k][j] ){ for( int p = 0; p < M; p++ ){ pair<int, int> p1 = {k, j}; pair<int, int> p2 = {j, k}; if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; p1 = {i, k}; p2 = {k, i}; if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; } } G[i][j] = min(G[i][j], G[i][k] + G[k][j]); } } } int ans = 0; for( int i = 0; i < M; i++ ){ if( fg.at(i) ) ans++; } cout << ans << endl; } }
a.cc:5:15: error: 'vector' does not name a type 5 | using Graph = vector<vector<int>>; | ^~~~~~ a.cc: In function 'int main()': a.cc:9:3: error: 'cin' was not declared in this scope 9 | cin >> N >> M; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | #define int long long a.cc:11:3: error: 'vector' was not declared in this scope 11 | vector<vector<int>> G(N, vector<int>(N, INF)); | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | #define int long long a.cc:1:13: error: expected primary-expression before 'long' 1 | #define int long long | ^~~~ a.cc:11:17: note: in expansion of macro 'int' 11 | vector<vector<int>> G(N, vector<int>(N, INF)); | ^~~ a.cc:12:10: error: 'pair' was not declared in this scope 12 | vector<pair<int, int>> E(M); | ^~~~ a.cc:1:1: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>' +++ |+#include <utility> 1 | #define int long long a.cc:1:13: error: expected primary-expression before 'long' 1 | #define int long long | ^~~~ a.cc:12:15: note: in expansion of macro 'int' 12 | vector<pair<int, int>> E(M); | ^~~ a.cc:13:32: error: 'G' was not declared in this scope 13 | for( int i = 0; i < N; i++ ) G.at(i).at(i) = 0; | ^ a.cc:18:5: error: 'G' was not declared in this scope 18 | G.at(A).at(B) = C; | ^ a.cc:20:5: error: 'E' was not declared in this scope 20 | E.at(i) = {A, B}; | ^ a.cc:23:10: error: expected primary-expression before 'bool' 23 | vector<bool> fg(M, true); | ^~~~ a.cc:27:13: error: 'G' was not declared in this scope 27 | if( G[i][j] > G[i][k] + G[k][j] ){ | ^ a.cc:1:13: error: expected primary-expression before 'long' 1 | #define int long long | ^~~~ a.cc:29:18: note: in expansion of macro 'int' 29 | pair<int, int> p1 = {k, j}; | ^~~ a.cc:1:13: error: expected primary-expression before 'long' 1 | #define int long long | ^~~~ a.cc:30:18: note: in expansion of macro 'int' 30 | pair<int, int> p2 = {j, k}; | ^~~ a.cc:31:17: error: 'E' was not declared in this scope 31 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^ a.cc:31:28: error: 'p1' was not declared in this scope; did you mean 'p'? 31 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^~ | p a.cc:31:45: error: 'p2' was not declared in this scope; did you mean 'p'? 31 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^~ | p a.cc:31:50: error: 'fg' was not declared in this scope 31 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^~ a.cc:32:13: error: 'p1' was not declared in this scope; did you mean 'p'? 32 | p1 = {i, k}; | ^~ | p a.cc:33:13: error: 'p2' was not declared in this scope; did you mean 'p'? 33 | p2 = {k, i}; | ^~ | p a.cc:34:17: error: 'E' was not declared in this scope 34 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^ a.cc:34:50: error: 'fg' was not declared in this scope 34 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^~ a.cc:37:9: error: 'G' was not declared in this scope 37 | G[i][j] = min(G[i][j], G[i][k] + G[k][j]); | ^ a.cc:37:19: error: 'min' was not declared in this scope; did you mean 'main'? 37 | G[i][j] = min(G[i][j], G[i][k] + G[k][j]); | ^~~ | main a.cc:44:9: error: 'fg' was not declared in this scope 44 | if( fg.at(i) ) ans++; | ^~ a.cc:46:3: error: 'cout' was not declared in this scope 46 | cout << ans << endl; | ^~~~ a.cc:46:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:46:18: error: 'endl' was not declared in this scope 46 | cout << ans << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | #define int long long a.cc: At global scope: a.cc:49:1: error: expected declaration before '}' token 49 | } | ^
s842256598
p03837
C++
#define int long long using namespace std; const int MOD = 1000000007; const int INF = 1e15; using Graph = vector<vector<int>>; signed main(){ int N, M; cin >> N >> M; vector<vector<int>> G(N, vector<int>(N, INF)); vector<pair<int, int>> E(M); for( int i = 0; i < N; i++ ) G.at(i).at(i) = 0; for( int i = 0; i < M; i++ ){ int A, B, C; cin >> A >> B >> C; A--; B--; G.at(A).at(B) = C; G.at(B).at(A) = C; E.at(i) = {A, B}; } vector<bool> fg(M, true); for (int k = 0; k < N; k++){ // 経由する頂点 for (int i = 0; i < N; i++) { // 始点 for (int j = 0; j < N; j++) { // 終点 if( G[i][j] > G[i][k] + G[k][j] ){ for( int p = 0; p < M; p++ ){ pair<int, int> p1 = {k, j}; pair<int, int> p2 = {j, k}; if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; p1 = {i, k}; p2 = {k, i}; if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; } } G[i][j] = min(G[i][j], G[i][k] + G[k][j]); } } } int ans = 0; for( int i = 0; i < M; i++ ){ if( fg.at(i) ) ans++; } cout << ans << endl; }
a.cc:5:15: error: 'vector' does not name a type 5 | using Graph = vector<vector<int>>; | ^~~~~~ a.cc: In function 'int main()': a.cc:9:3: error: 'cin' was not declared in this scope 9 | cin >> N >> M; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | #define int long long a.cc:11:3: error: 'vector' was not declared in this scope 11 | vector<vector<int>> G(N, vector<int>(N, INF)); | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | #define int long long a.cc:1:13: error: expected primary-expression before 'long' 1 | #define int long long | ^~~~ a.cc:11:17: note: in expansion of macro 'int' 11 | vector<vector<int>> G(N, vector<int>(N, INF)); | ^~~ a.cc:12:10: error: 'pair' was not declared in this scope 12 | vector<pair<int, int>> E(M); | ^~~~ a.cc:1:1: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>' +++ |+#include <utility> 1 | #define int long long a.cc:1:13: error: expected primary-expression before 'long' 1 | #define int long long | ^~~~ a.cc:12:15: note: in expansion of macro 'int' 12 | vector<pair<int, int>> E(M); | ^~~ a.cc:13:32: error: 'G' was not declared in this scope 13 | for( int i = 0; i < N; i++ ) G.at(i).at(i) = 0; | ^ a.cc:18:5: error: 'G' was not declared in this scope 18 | G.at(A).at(B) = C; | ^ a.cc:20:5: error: 'E' was not declared in this scope 20 | E.at(i) = {A, B}; | ^ a.cc:23:10: error: expected primary-expression before 'bool' 23 | vector<bool> fg(M, true); | ^~~~ a.cc:27:13: error: 'G' was not declared in this scope 27 | if( G[i][j] > G[i][k] + G[k][j] ){ | ^ a.cc:1:13: error: expected primary-expression before 'long' 1 | #define int long long | ^~~~ a.cc:29:18: note: in expansion of macro 'int' 29 | pair<int, int> p1 = {k, j}; | ^~~ a.cc:1:13: error: expected primary-expression before 'long' 1 | #define int long long | ^~~~ a.cc:30:18: note: in expansion of macro 'int' 30 | pair<int, int> p2 = {j, k}; | ^~~ a.cc:31:17: error: 'E' was not declared in this scope 31 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^ a.cc:31:28: error: 'p1' was not declared in this scope; did you mean 'p'? 31 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^~ | p a.cc:31:45: error: 'p2' was not declared in this scope; did you mean 'p'? 31 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^~ | p a.cc:31:50: error: 'fg' was not declared in this scope 31 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^~ a.cc:32:13: error: 'p1' was not declared in this scope; did you mean 'p'? 32 | p1 = {i, k}; | ^~ | p a.cc:33:13: error: 'p2' was not declared in this scope; did you mean 'p'? 33 | p2 = {k, i}; | ^~ | p a.cc:34:17: error: 'E' was not declared in this scope 34 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^ a.cc:34:50: error: 'fg' was not declared in this scope 34 | if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false; | ^~ a.cc:37:9: error: 'G' was not declared in this scope 37 | G[i][j] = min(G[i][j], G[i][k] + G[k][j]); | ^ a.cc:37:19: error: 'min' was not declared in this scope; did you mean 'main'? 37 | G[i][j] = min(G[i][j], G[i][k] + G[k][j]); | ^~~ | main a.cc:44:9: error: 'fg' was not declared in this scope 44 | if( fg.at(i) ) ans++; | ^~ a.cc:46:3: error: 'cout' was not declared in this scope 46 | cout << ans << endl; | ^~~~ a.cc:46:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:46:18: error: 'endl' was not declared in this scope 46 | cout << ans << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | #define int long long
s319525032
p03837
C++
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; using namespace std; const long long int INF = 1e18; const long long int mod = 1e9+7; typedef pair<ll, ll> pairs; typedef vector<pairs> p; struct Edge{ ll to, weight; Edge(ll t, ll w) : to(t), weight(w){} }; using graph = vector<vector<ll>>; using Graph = vector<vector<Edge>>; ll gcd(ll a,ll b){ if(b == 0){ return a; }else{ return gcd(b, a%b); } } ll lcm(ll a, ll b){ return a / gcd(a, b) * b; } ll keta(ll N){ ll M = 1; while( N > 0 ){ if(N / 10 == 0){ break; } N /= 10; M++; } return M; } // 回文 bool kai(string S){ bool flag = true; for(ll i=0;i<S.size()/2;++i){ if(S[i] != S[S.size()-i-1]){ flag = false; break; } } return flag; } // --------------------------------------------- int main(){ ll n, m; cin>>n>>m; ll g[n][n]; for(ll i=0;i<n;++i){ for(ll j=0;j<n;++j){ if(i == j){ g[i][j] = 0; }else{ g[i][j] = INF; } } } vector<ll> a(m), b(m), c(m); for(ll i=0;i<m;++i){ cin>>a[i]>>b[i]>>c[i]; a[i]--; b[i]--; g[a[i]][b[i]] = min(g[a[i][b[i]], c[i]); g[b[i]][a[i]] = min(g[b[i][a[i]], c[i]]); } for(ll k=0;k<n;++k){ for(ll i=0;i<n;++i){ for(ll j=0;j<n;++j){ g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } } } ll ans = m; for(ll i=0;i<m;++i){ bool flag = false; for(ll j=0;j<n;++j){ if(g[j][a[i]] + c[i] == g[j][b[i]]){ flag = true; } } if(flag){ ans--; } } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:74:35: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript 74 | g[a[i]][b[i]] = min(g[a[i][b[i]], c[i]); | ^ a.cc:74:47: error: expected ']' before ')' token 74 | g[a[i]][b[i]] = min(g[a[i][b[i]], c[i]); | ^ | ] a.cc:75:35: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript 75 | g[b[i]][a[i]] = min(g[b[i][a[i]], c[i]]); | ^
s124920453
p03837
C++
#include <iostream> #include <vector> #include <algorithm> #include <ctime> #include <cmath> #include <string> #include <stdlib.h> #include <fstream> #include <set> #include <map> #include <queue> #include <stack> #include <deque> #include <iterator> #include <iomanip> #include <climits> using namespace std; long long n; vector<vector<pair<long long, long long> > > g; set<pair<long long, long long> > st; void dijkstra(long long s){ vector<int> d (n, 1e9), p (n, -1); d[s] = 0; set < pair<int,int> > q; q.insert (make_pair (d[s], s)); while (!q.empty()) { int v = q.begin()->second; q.erase (q.begin()); for (size_t j=0; j<g[v].size(); ++j) { int to = g[v][j].first, len = g[v][j].second; if (d[v] + len < d[to]) { q.erase (make_pair (d[to], to)); d[to] = d[v] + len; p[to] = v; q.insert (make_pair (d[to], to)); } } } for(int i = 0; i < n; ++n){ if(p[i] == -1) continue; long long a = max(i, p[i]), b = min(i, p[i]); s.insert({a, b}); } } int main(){ long long n, m; cin >> n >> m; g.resize(n, vector<pair<long long, long long> >(n)); for(int i = 0; i < m; ++i){ long long fr, to, w; cin >> fr >> to >> w; fr--, to--; g[fr].push_back({to, w}); g[to].push_back({fr, w}); } for(int i = 0; i < n; ++i) dijkstra(i); cout << m - s.size(); }
a.cc: In function 'void dijkstra(long long int)': a.cc:46:11: error: request for member 'insert' in 's', which is of non-class type 'long long int' 46 | s.insert({a, b}); | ^~~~~~ a.cc: In function 'int main()': a.cc:64:17: error: 's' was not declared in this scope 64 | cout << m - s.size(); | ^
s528262012
p03837
C++
#include<bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; using P = pair<int, int>; const long long INF = 100000000; //ダイクストラ法の練習 int main(){ int N,M; cin >> N >> M; vector<vector<int>> edge(101, vector<int> (0)); vector<vector<int>> L(101, vector<int> (101) ); rep(i, M){ int a, b,c; cin >>a>>b>>c; edge[a].push_back(b); edge[b].push_back(a); L[a][b] = c; L[b][a] = c; } vector<vector<int>> min_dist(101, vector<int> (101)) //スタートがi for(int i = 1; i < N; i++){ //int i = 1;//テスト //準備 priority_queue<P, vector<P>, greater<P>> pq;//pair<仮の距離、頂点>仮の距離が小さい順に並ぶ vector<int> dist(N+1, INF);//スタートからの最短距離を更新し続ける //初期条件 dist[0] = 0;//頂点0は使わない dist[i] = 0;//頂点iまでの距離は0 pq.push(make_pair(dist[i], i)); //jが確定するまで続ける while(!pq.empty()){ P p = pq.top();//仮距離最小を取り出す pq.pop();//削除する int v = p.second;//頂点を取り出す //更新しない場合 //if(dist[v] < p.first){ // continue; // } //更新する場合,vから行けるすべての頂点に対して for(int u:edge[v]){ if(dist[v]+L[v][u] < dist[u]){ dist[u] = dist[v]+L[v][u]; pq.push(make_pair(dist[u], u)); } } } //記録する for(int j = i+1; j <= N; j++){ min_dist[i][j] = dist[j]; } } rep(i, N+1){ rep(j, N+1){ cout << min_dist[i][j] << " " << endl; } cout << endl; } }
a.cc: In function 'int main()': a.cc:26:3: error: expected ',' or ';' before 'for' 26 | for(int i = 1; i < N; i++){ | ^~~ a.cc:26:18: error: 'i' was not declared in this scope 26 | for(int i = 1; i < N; i++){ | ^
s568630275
p03837
Java
import java.util.Scanner; public class CandidatesOfNoShortestPaths { public static void main(String[] args){ Scanner scan=new Scanner(System.in); int num_vertex=scan.nextInt(); int num_edge=scan.nextInt(); int[] a=new int[num_edge]; int[] b=new int[num_edge]; int[] c=new int[num_edge]; int i; for(i=0;i<num_edge;i++){ a[i]=scan.nextInt(); b[i]=scan.nextInt(); c[i]=scan.nextInt(); } int[] count=new int[num_edge]; for(i=0;i<num_edge;i++){ count[i]=0; } int j=0; int use=0; for(i=0;i<num_edge;i++){ int min_d=1000; for(j=i+1;j<num_edge;j++){ for(int k=0;k<num_edge;k++){ if(a[k]==i && b[k]==j){ if(min_d>c[k]){ use=k; } } } count[use]++; } } int answer=0; for(i=0;i<num_edge;i++){ if(count[i]==0){ answer++; } } System.out.println(answer); } }
Main.java:2: error: class CandidatesOfNoShortestPaths is public, should be declared in a file named CandidatesOfNoShortestPaths.java public class CandidatesOfNoShortestPaths { ^ 1 error
s835994416
p03837
Java
import java.util.Scanner; public class CandidatesOfNoShortestPaths { public static void main(String[] args){ Scanner scan=new Scanner(System.in); int num_vertex=scan.nextInt(); int num_edge=scan.nextInt(); int[] a=new int[num_edge]; int[] b=new int[num_edge]; int[] c=new int[num_edge]; int i; for(i=0;i<num_edge;i++){ a[i]=scan.nextInt(); b[i]=scan.nextInt(); c[i]=scan.nextInt(); } int[] count=new int[num_edge]; for(i=0;i<num_edge;i++){ count[i]=0; } int j=0; int use; for(i=0;i<num_edge;i++){ int min_d=1000; for(j=i+1;j<num_edge;j++){ for(int k=0;k<num_edge;k++){ if(a[k]=i && b[k]==j){ if(min_d>c[k]){ use=k; } } } count[use]++; } } int answer=0; for(i=0;i<num_edge;i++){ if(count[i]==0){ answer++; } } System.out.println(answer); } }
Main.java:2: error: class CandidatesOfNoShortestPaths is public, should be declared in a file named CandidatesOfNoShortestPaths.java public class CandidatesOfNoShortestPaths { ^ Main.java:27: error: bad operand types for binary operator '&&' if(a[k]=i && b[k]==j){ ^ first type: int second type: boolean Main.java:27: error: incompatible types: int cannot be converted to boolean if(a[k]=i && b[k]==j){ ^ 3 errors
s446831875
p03837
C++
#include <bits/stdc++.h> using namespace std; // Type alias using ll=long long; using ld=double; using pi=pair<int,int>; using pll=pair<ll,ll>; using pld=pair<ld,ld>; using ti3=tuple<int, int, int>; using vi=vector<int>; using vll=vector<ll>; using vld=vector<ld>; using vpi=vector<pi>; using vpll=vector<ll>; using vpld=vector<ld>; using vti3=vector<ti3>; // Constants const double EPS = 1e-9; const int inf = numeric_limits<int>::max(); // Macro #define rep(i,n) for(int i=0;i<int(n);++i) #define rrep(i,n) for(int i=int(n-1);i>=0;--i) #define REP(i,a,b) for(int i=int(a);i<int(b);++i) #define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i) #define SHOW(a) cout << #a << " = " << a << endl #define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl #define ALL(a) a.begin(),a.end() // Funtcions ll pow(ll base, ll i, ll mod){ ll a = 1; while(i){ if (i & 1) { a *= base; a %= mod; } base *= base; base %= mod; i >>= 1; } return a; } ll gcd(ll a, ll b){ while(b){ ll c = a % b; a = b; b = c; } return a; } ll lcm(ll a, ll b){ return a / gcd(a, b) * b; } template<typename T> bool chmin(T& a, const T& b) { if (a > b) return a = b, true; else return false; } template<typename T> bool chmax(T& a, const T& b) { if (a < b) return a = b, true; else return false; } void solve(){ int N, M; cin >> N >> M; int C[105][105] = {}; vector<vector<pi>> w(N, vector<pi>(0)); rep(i, N)rep(j, N) C[i][j] = inf / 2; rep(i, N) dist[i][i] = 0; rep(i, M){ int a, b, c; cin >> a >> b >> c; a--; b--; C[a][b] = c; C[b][a] = c; w[a].emplace_back(make_pair(b, c)); w[b].emplace_back(make_pair(a, c)); } rep(k, N){ rep(i, N){ rep(j, N){ C[i][j] = min(C[i][j], C[i][k] + C[k][j]); } } } bool used[105][105] = {}; rep(i, N){ rep(j, N){ for(auto e: w[j]){ int node = e.first; int cost = e.second; if(C[i][node] + cost == C[i][j]){ used[node][j] = true; used[j][node] = true; } } } } int sum = 0; rep(i, N){ rep(j, N){ if(used[i][j]) sum++; } } cout << M - sum / 2 << endl; } int main(){ // FastIO //ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:77:13: error: 'dist' was not declared in this scope 77 | rep(i, N) dist[i][i] = 0; | ^~~~
s806700160
p03837
C++
#include<iostream> using namespace std; int main(void){ 2 const int inf = 100000000; 3 3 4 int n,m; 5 cin >> n >> m; 6 7 int a[1000],b[1000],c[1000],dist[100][100]; 8 9 for(int i = 0; i < m; ++i){ 10 cin >> a[i] >> b[i] >> c[i]; 11 a[i]--,b[i]--; 12 } 13 14 for(int i = 0; i < n; ++i){ 15 for(int j = 0; j < n; ++j){ 16 if(i==j) 17 dist[i][j]=0; 18 else 19 dist[i][j]=inf; 20 } 21 } 22 23 for(int i = 0; i < m; ++i){ 24 dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]); 25 dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]); 26 } 27 28 for(int k = 0; k < n; ++k){ 29 for(int i = 0; i < n; ++i){ 30 for(int j = 0; j < n; ++j){ 31 dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]); 32 } 33 } 34 } 35 36 int ans=m; 37 for(int i = 0; i < m; ++i){ 38 bool shortest=false; 39 for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true; 40 if(shortest==true){ 41 ans=ans-1; 42 } 43 } 44 45 cout << ans << endl; 46 }
a.cc: In function 'int main()': a.cc:4:2: error: expected ';' before 'const' 4 | 2 const int inf = 100000000; | ^~~~~~ | ; a.cc:5:2: error: expected ';' before numeric constant 5 | 3 | ^ | ; 6 | 3 | ~ a.cc:8:2: error: expected ';' before 'cin' 8 | 5 cin >> n >> m; | ^~~~ | ; a.cc:9:2: error: expected ';' before numeric constant 9 | 6 | ^ | ; 10 | 7 int a[1000],b[1000],c[1000],dist[100][100]; | ~ a.cc:11:2: error: expected ';' before numeric constant 11 | 8 | ^ | ; 12 | 9 for(int i = 0; i < m; ++i){ | ~ a.cc:12:18: error: 'i' was not declared in this scope 12 | 9 for(int i = 0; i < m; ++i){ | ^ a.cc:12:22: error: 'm' was not declared in this scope; did you mean 'tm'? 12 | 9 for(int i = 0; i < m; ++i){ | ^ | tm a.cc:16:3: error: expected ';' before numeric constant 16 | 13 | ^ | ; 17 | 14 for(int i = 0; i < n; ++i){ | ~~ a.cc:17:23: error: 'n' was not declared in this scope 17 | 14 for(int i = 0; i < n; ++i){ | ^ a.cc:25:3: error: expected ';' before numeric constant 25 | 22 | ^ | ; 26 | 23 for(int i = 0; i < m; ++i){ | ~~ a.cc:30:3: error: expected ';' before numeric constant 30 | 27 | ^ | ; 31 | 28 for(int k = 0; k < n; ++k){ | ~~ a.cc:31:19: error: 'k' was not declared in this scope 31 | 28 for(int k = 0; k < n; ++k){ | ^ a.cc:38:3: error: expected ';' before numeric constant 38 | 35 | ^ | ; 39 | 36 int ans=m; | ~~ a.cc:40:3: error: expected ';' before 'for' 40 | 37 for(int i = 0; i < m; ++i){ | ^~~~ | ; a.cc:47:3: error: expected ';' before numeric constant 47 | 44 | ^ | ; 48 | 45 cout << ans << endl; | ~~ a.cc:49:3: error: expected ';' before '}' token 49 | 46 } | ^~ | ;
s667468037
p03837
C++
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i) #define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i > 0; i--) #define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i) #define SORT(v, n) sort(v, v + n); #define REVERSE(v, n) reverse(v, v+n); #define vsort(v) sort(v.begin(), v.end()); #define all(v) v.begin(), v.end() #define mp(n, m) make_pair(n, m); #define cout(d) cout<<d<<endl; #define coutd(d) cout<<std::setprecision(10)<<d<<endl; #define cinline(n) getline(cin,n); #define replace_all(s, b, a) replace(s.begin(),s.end(), b, a); #define PI (acos(-1)) #define FILL(v, n, x) fill(v, v + n, x); #define sz(x) int(x.size()) using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using pii = pair<int, int>; using pll = pair<ll, ll>; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF = 1e9; const int MOD = 1e9+7; const ll LINF = 1e18; const ll maxv=105; int dist[maxv][maxv]; int n; void warshallfloyd(){ for(int k = 0; k < n; k++) for(int i = 0; i < n; i ++) for(int j = 0; j < n; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } signed main() { cin.tie( 0 ); ios::sync_with_stdio( false ); ll m; cin>>n>>m; rep(i,n) rep(j,n) dist[i][j]=INF; vector<tuple<ll,ll,ll>> es; rep(i,m){ ll a,b,c; cin>>a>>b>>c; a--,b--; es.emplace_back(a,b,c); dist[a][b]=dist[b][a]=c; } warshall_floyd(); ll ans=0; rep(i,m){ ll a,b,c; tie(a,b,c)=es[i]; if(dist[a][b]<c) ans++; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:63:3: error: 'warshall_floyd' was not declared in this scope; did you mean 'warshallfloyd'? 63 | warshall_floyd(); | ^~~~~~~~~~~~~~ | warshallfloyd
s277215852
p03837
C++
# include <iostream> using namespace std; int main(){ int N, M; int a, b, c, count; int d[100][100], dc[100][100]; // load the graph for(int m = 0; m < M; m++) { cin >> a >> b >> c; d[a][b] = c; d[b][a] = c; } dc = d; for(int k = 0; k < N; k++) { for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } count = 0; for (int n = 0; n < N; n++) { for (int m = n; m < N; m++) { if (d[n][m] - dc[n][m] < 0) { count ++; } } } cout << count << endl; return 0; }
a.cc: In function 'int main()': a.cc:18:6: error: invalid array assignment 18 | dc = d; | ~~~^~~
s826627014
p03837
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<vector> #include<map> using namespace std; typedef long long ll; typedef pair<int, int> P; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define sc(x) scanf("%d",&x); static const int MAX = 100; static const int INF = 1e7; int n, m, d[MAX][MAX]; vector<pair<int, P> > v; void warshall_floyd(){ for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ for (int k = 0; k < n; k++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } int check(){ int res = 0; bool short; for (int i = 0; i < m; i++){ short = true; for (int j = 0; j < n; j++){ if (!short) break; if (d[j][v[i].second.first] + v[i].first \ == d[j][v[i].second.second]){ if (short) res += 1; short = false; } } } return res; } int main(){ int a, b, c, ans; sc(n) sc(m) for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++) d[i][j] = INF; d[i][i] = 0; } for (int i = 0; i < m; i++){ sc(a) sc(b) sc(c) d[a - 1][b - 1] = c; d[b - 1][a - 1] = c; v.push_back(make_pair(c, P(a - 1, b - 1))); } warshall_floyd(); ans = check(); cout << m - ans << endl; return 0; }
a.cc: In function 'int check()': a.cc:28:10: error: declaration does not declare anything [-fpermissive] 28 | bool short; | ^~~~~ a.cc:30:15: error: expected unqualified-id before '=' token 30 | short = true; | ^ a.cc:32:18: error: expected primary-expression before 'short' 32 | if (!short) break; | ^~~~~ a.cc:32:18: error: expected ')' before 'short' 32 | if (!short) break; | ~ ^~~~~ | ) a.cc:35:26: error: expected unqualified-id before ')' token 35 | if (short) res += 1; | ^ a.cc:36:23: error: expected unqualified-id before '=' token 36 | short = false; | ^
s756615716
p03837
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++) #define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++) #define MOD 1000000007 #define int long long #define ALL(a) (a).begin(),(a).end() #define vi vector<int> #define vii vector<vi> #define pii pair<int,int> #define priq priority_queue<int> #define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key))) #define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key))) #define tii tuple<int,int,int> #define Priq priority_queue<int,vi,greater<int>> #define pb push_back #define mp make_pair #define INF (1ll<<60) signed main(){ int N,M; cin>>N>>M; vii A(N,vi(N,INF)); rep(i,0,M){ int X,Y,Z; cin>>X>>Y>>Z; A[X-1][Y-1]=Z; A[Y-1][X-1]=Z; } vector<vector<bool>> F(N,vi(N)); rep(i,0,N){ vi memo(N); memo[i]=-1; priority_queue<pii,vector<pii>,greater<pii>> Q; Q.push(mp(0,i)); vi B(N,MOD); B[i]=0; while(Q.size()>0){ int X=Q.top().second,Y=Q.top().first; Q.pop(); rep(j,0,N){ if(B[j]>=Y+A[X][j]){ B[j]=Y+A[X][j]; Q.push(mp(Y+A[X][j],j)); memo[i]=X; } } } rep(i,0,N){ int P=i; while(memo[P]!=-1){ F[P][memo[P]]=1; P=memo[P]; } } } int ans=0; rep(i,0,N){ rep(j,0,N){ if(F[i][j]) ans++; } } cout<<M-ans/2<<endl; }
a.cc: In function 'int main()': a.cc:27:33: error: no matching function for call to 'std::vector<std::vector<bool> >::vector(long long int&, std::vector<long long int>)' 27 | vector<vector<bool>> F(N,vi(N)); | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]' 707 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed: a.cc:27:33: note: deduced conflicting types for parameter '_InputIterator' ('long long int' and 'std::vector<long long int>') 27 | vector<vector<bool>> F(N,vi(N)); | ^ /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; allocator_type = std::allocator<std::vector<bool> >]' 678 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'long long int' to 'std::initializer_list<std::vector<bool> >' 678 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<bool> >]' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'long long int' to 'std::vector<std::vector<bool> >&&' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ~~~~~~~~~^~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; allocator_type = std::allocator<std::vector<bool> >; std::false_type = std::false_type]' 640 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; allocator_type = std::allocator<std::vector<bool> >; std::true_type = std::true_type]' 635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<bool> >]' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'long long int' to 'const std::vector<std::vector<bool> >&' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]' 620 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]' 601 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; size_type = long unsigned int; value_type = std::vector<bool>; allocator_type = std::allocator<std::vector<bool> >]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'std::vector<long long int>' to 'const std::vector<std::vector<bool> >::value_type&' {aka 'const std::vector<bool>&'} 569 | vector(size_type __n, const value_type& __value, | ~~~~~~~~~~~~~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<bool> >]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'std::vector<long long int>' to 'const std::vector<std::vector<bool> >::allocator_type&' {aka 'const std::allocator<std::vector<bool> >&'} 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; allocator_type = std::allocator<std::vector<bool> >]' 542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]' 531 | vector() = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided
s660459644
p03837
Java
import java.*; public class Main { public static final int inf = 1000000000; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), m = sc.nextInt(); int[][] in = new int[m][3];//from to cost int[][] sp = new int[n][n]; int ans_ = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { sp[i][j] = inf; } } for (int i = 0; i < m; i++) { in[i][0] = sc.nextInt()-1; in[i][1] = sc.nextInt()-1; in[i][2] = sc.nextInt(); sp[in[i][0]][in[i][1]] = in[i][2]; sp[in[i][1]][in[i][0]] = in[i][2]; } for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { sp[i][j] = Math.min(sp[i][j], sp[i][k]+sp[k][j]); } } } Dijkstra d = new Dijkstra(n); int[] dist1 = new int[n]; int[] dist2 = new int[n]; for (int i = 0; i < m; i++) d.addNode(in[i][0],in[i][1],in[i][2]); for (int i = 0; i < m; i++) { d.initialize(); d.dijkstra(in[i][0]); dist1 = d.dist.clone(); d.initialize(); d.dijkstra(in[i][1]); dist2 = d.dist.clone(); System.out.println(); OUT:for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { if(j != k) { if(dist1[j]+in[i][2]+dist2[k] == sp[j][k]) { ans_++; break OUT; } } } } } System.out.println(m-ans_); } public static void print(int[][] array) { for (int i = 0; i < array.length; i++) { System.out.println(Arrays.toString(array[i])); } } public static class Dijkstra { Node[] list; int[] dist; public Dijkstra(int n) { list = new Node[n]; dist = new int[n]; for (int i = 0; i < list.length; i++) { list[i] = new Node(); dist[i] = inf; } } public void dijkstra(int s) { dist[s] = 0; PriorityQueue<Pair> que = new PriorityQueue<Pair>( new Comparator<Pair>(){ public int compare(Pair a, Pair b) { return b.getDist()-a.getDist(); } } ); Pair p = new Pair(s, dist[s]); que.add(p); while(!que.isEmpty()) { p = que.poll(); int v = p.getVer(); if(dist[v] < p.getDist()) continue; for (int i = 0; i < list[v].size(); i++) { Edge e = list[v].get(i); if(dist[e.to] > dist[v] + e.cost) { dist[e.to] = dist[v] + e.cost; que.add(new Pair(e.to, dist[e.to])); } } } } public void initialize() { Arrays.fill(dist, inf); return; } public void addNode(int from, int to, int cost) {// Edge e = new Edge(to, cost); Edge e_reverse = new Edge(from, cost); list[from].addEdge(e); list[to].addEdge(e_reverse); } class Node{ ArrayList<Edge> edges; public Node() { edges = new ArrayList<Edge>(); } public void addEdge(Edge e) { edges.add(e); } public int size() { return edges.size(); } public Edge get(int i) { return edges.get(i); } } class Edge { int to; int cost; public Edge(int to, int cost) { this.to = to; this.cost = cost; } } class Pair{ private ArrayList<Integer> pair; public Pair(int from, int distance) { pair = new ArrayList<Integer>(); pair.add(from); pair.add(distance); } public int getVer() { return pair.get(0); } public int getDist() { return pair.get(1); } } } }
Main.java:1: error: package java does not exist import java.*; ^ Main.java:120: error: cannot find symbol ArrayList<Edge> edges; ^ symbol: class ArrayList location: class Dijkstra.Node Main.java:145: error: cannot find symbol private ArrayList<Integer> pair; ^ symbol: class ArrayList location: class Dijkstra.Pair Main.java:7: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:7: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:64: error: cannot find symbol System.out.println(Arrays.toString(array[i])); ^ symbol: variable Arrays location: class Main Main.java:84: error: cannot find symbol PriorityQueue<Pair> que = new PriorityQueue<Pair>( ^ symbol: class PriorityQueue location: class Dijkstra Main.java:84: error: cannot find symbol PriorityQueue<Pair> que = new PriorityQueue<Pair>( ^ symbol: class PriorityQueue location: class Dijkstra Main.java:85: error: cannot find symbol new Comparator<Pair>(){ ^ symbol: class Comparator location: class Dijkstra Main.java:108: error: cannot find symbol Arrays.fill(dist, inf); ^ symbol: variable Arrays location: class Dijkstra Main.java:122: error: cannot find symbol edges = new ArrayList<Edge>(); ^ symbol: class ArrayList location: class Dijkstra.Node Main.java:147: error: cannot find symbol pair = new ArrayList<Integer>(); ^ symbol: class ArrayList location: class Dijkstra.Pair 12 errors
s224710109
p03837
C++
#include <iostream> #include <bits/stdc++.h> using namespace std; const int INF = 1<<29; const int MAX_V = 110; const int MAX_E = 1100; int N, M; int a[MAX_E], b[MAX_E], c[MAX_E]; //各辺 int dist[MAX_V][MAX_V] //Warshall-Floyd用 int main(){ cin >> N >> M; //Warshall-Floydでよくやる初期化 for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ dist[i][j] = INF; } dist[i][i] = 0; //自分自身への距離は0 } //input for (int i = 0; i < M; i++){ cin >> a[i] >> b[i] >> c[i]; a[i]--, b[i]--; dist[a[i]][b[i]] = c[i]; dist[b[i]][a[i]] = c[i]; } // Warshall-floyd for (int k = 0; k < N; k++){ for (int i = 0; i < N; i++){ for (int j = 0; j < N: j++){ dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } } int res = 0; for (int i = 0 ; i < M; i++){ if (c[i] > dist[a[i]b[i]]) res++; } cout << res << endl; }
a.cc:16:1: error: expected initializer before 'int' 16 | int main(){ | ^~~
s638882599
p03837
C++
#include <bits/stdc++.h> //#include <mylib.h> using namespace std; //cin.sync_with_stdio(false); #define FOR(i,a,b) for(ll i = (a); i < (b); ++i) #define FOR_EQ(i,a,b) for(ll i = (a); i <= (b); ++i) #define FOR_RE(i,a,b) for(ll i = (a); i >= (b); --i) // 終端を0じゃなくて、1まですることによってn回。感覚的に1以上にしておいた。 #define rep(i,n) FOR(i,0,n) #define rep_eq(i,n) FOR_EQ(i,0,n) #define rep_re(i,n) FOR_RE(i,n,0) #define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl #define INFTY (1 << 21) //10^21 #define INF (1 << 9) #define WHITE 1//(未訪問) #define GRAY 2//(訪問)未だに訪問していない頂点への辺を持っている。スタックに退避。 #define BLACK 3//(訪問完了)未訪問への頂点への辺を持たない #define MAX 100000 /* #define N 100 int M[N][N];// 隣接行列(頂点と頂点が繋がってる、もしくは重みの値) int color[N]; // その頂点の探索具合 */ const int TABLEMAX = 510000; const int MOD = 1000000007; //二項係数用の各階乗の値とその逆元を記録するための配列. long long fac[TABLEMAX], finv[TABLEMAX], inv[TABLEMAX]; //1個上から時計周り const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; //上右下左 const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {-1, 0, 1, 0}; static const int NIL = -1; typedef unsigned long long ull; typedef long long ll; typedef vector<ll> Vector; typedef vector<Vector> DVector; typedef vector<pair<ll, ll>> Vec_Pair; // 関数prime_factorizationで使う。 // 因数分解で使う。firstは数。secondは指数。 vector<pair<ll, ll>> prime_factor; // 関数get_factor_listで使う。因数の一覧を取得で使う。 Vector factor_list; // 2つともエラトステネスの篩で使う。 vector<bool> prime; // 素数かどうか判定。 Vector prime_num; // 素数を記録。 ll n; template <class X> void printArray(X *array, ll); template <class X> void printVector(vector<X> &v); template <class X> void printDimention(vector<vector<X>> &dv); template <class X> void printMap(X); template <class X> void printVecPair(vector<X> &v); // 何個2がかかっているか ll factor2(ll); //nCr方式で組み合わせの数を求める ll combination(int, int); //nPrで階乗を求める int factorial(int, int); //桁数を返す int find_digits(int); // 各桁の和を計算する関数 int findSumOfDigits(int); //次数を得る int degree(int); //四捨五入 int shishagonyu(double); //切り上げ int roundUp(double); //切り捨て int roundDown(double); //四捨五入 int roundOff(double); //最大公約数(Greatest Common Divisor) ll gcd (ll, ll); //最小公倍数(Least Common Multiple) ll lcm(ll, ll); //素因数分解 void prime_factorization(ll); //エラトステネスの篩 void Eratosthenes(int); //偶奇判定。奇数ならtrue。 bool odd_even(int); //aのmod mにおける逆元を計算する long long modinv(long long, long long); // a^n mod を計算する(二分累乗) long long modpow(long long, long long, long long); //テーブルを作る前処理 void COMinit(); //二項係数計算 nCk, 1 <= k <= n <= 10^7 long long COM(int, int); // longlong型で絶対値を帰す。 long long abs_ll(ll); // 割り算した時に余りが有る時だけ、+1の商を返す。 long long div_one(ll, ll); // Stringの各桁をvectorの配列に入れる。でかい桁が添字0。 template <class X> void StringtoVec(string, vector<X> &v); // 因数の一覧を取得する void get_factor_list(ll); vector<vector<ll>> map; vector<ll> color; vector<ll> d; vector<ll> p; ll cnt = 0; void dijkstra(){ ll minv, u = 0; p[0] = 0; d[0] = 0; while(1){ // set部 // V-Tの一番コストの低いノードを選ぶ minv = INFTY; u - 1; rep(v, n){ if(color[v] != BLACK && d[v] < minv){ minv = map[u][v]; u = i; } } if(minv == INFTY || u == -1) break; color[u] = BLACK; // 辺の更新 rep(v, n){ if(color[v] != BLACK && map[u][v] != 0){ if(d[u] + map[u][v] < d[v]){ d[v] = d[u] + map[u][v]; p[v] = u; color[v] = GRAY; } } } } } void dijkstra_init(){ rep(i, n){ color[i] = WHITE; d[i] = INFTY; p[i] = -1; } dijkstra(); } int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); ll m; cin >> n >> m; map.resize(n); rep(i, n) map[i].resize(n); rep(i, m){ ll a, b, c; cin >> a >> b >> c; map[a][b] = c; } dijkstra_init(); cnt = n - 1; cout << m - cnt << endl; return 0; } template<class X> void printArray(X array[], ll n){ rep(i, n){ if(i) cout << " "; cout << array[i]; } cout << endl; } template<class X> void printVector(vector<X> &v){ rep(i, (int)v.size()){ if(i) cout << " "; cout << v[i]; } cout << endl; } //二次元配列の表示 template<class X> void printDimention(vector<vector<X>> &dv){ rep(i, (ll)dv.size()){ rep(j, (ll)dv[i].size()){ if(j) cout << " "; cout << dv[i][j]; } cout << endl; } } //mapの表示 template <class X> void printMap(X mp) { for (auto it : mp) { cout << it.first << " " << it.second << endl; } } // 内部にpairを内包したvectorの表示 template <class X> void printVecPair(vector<X> &v){ rep(i, (int)v.size()){ cout << v[i].first << " " << v[i].second << endl; } cout << endl; } //numの中に何個2がかかってるか ll factor2(ll num){ int cnt = 0; while(num % 2 == 0){ num /= 2; cnt++; } return cnt; } //nCr方式で組み合わせの数を求める ll combination(int n, int r){ ll up = 1, down = 1; // 以下2行はお試し ll half = n / 2; if(r >= half) r = n - r; ll up_tmp = n, down_tmp = r; if(r == 0) return 1; rep(i, r){ up *= up_tmp; up_tmp--; down *= down_tmp; down_tmp--; } return up/down; } //nPr方式で階乗を求める int factorial(int n, int r){ if(n < r){ cout << "error" << endl; return 0; }else{ int res = 1; while(r){ r--; res *= n; n--; } return res; } } //桁数を返す int find_digits(int n){ int digit = 0; while(n){ n /= 10; digit++; } return digit; } // 各桁の和を計算する関数 int findSumOfDigits(int n){ int sum = 0; while (n > 0) { // n が 0 になるまで sum += n % 10; n /= 10; } return sum; } //次数を得る int degree(int n){ int count = 0; while(1){ if(count <= 0) break; count /= 2; count++; } return count; } //四捨五入 int shishagonyu( double x ) { return (int)( x < 0.0 ? x-0.5 : x+0.5 ); } //切り上げ int roundUp(double n){ if(n >= 0){ return (int)n + 1; }else{ return (int)n - 1; } } //切り捨て int roundDown(double n){ return (int)n; } //四捨五入 int roundOff(double n){ double decimal = 0; decimal = n - (int)n; if(decimal >= 0.5 || decimal <= -0.5){ return roundUp(n); }else{ return roundDown(n); } } //最大公約数(Greatest Common Divisor) ll gcd (ll m, ll n){ //引数に0がある場合は0を返す if(m == 0 || n == 0) return 0; //ユークリッドの互除法 while(m != n){ if(m > n) m = m - n; else n = n - m; } return m; } //最小公倍数(Least Common Multiple) ll lcm(ll m, ll n){ //引数に0がある場合は0を返す if(m == 0 || n == 0) return 0; //lcm = m * n / gcd(m, n) return ((m / gcd(m, n)) * n); } //素因数分解 firstは数。secondは指数。 void prime_factorization(ll n){ int div = 2, res; bool flg = false; if(n < 2){ cout << "Error" << endl; return; } while(n >= div * div){ if(n % div == 0){ res = div; //resをグローバルな配列に代入すれば記録できる。 if(flg){ prime_factor[prime_factor.size() - 1].second++; }else{ prime_factor.push_back(make_pair(0, 1)); prime_factor[prime_factor.size() - 1].first = res; } n /= div; flg = true; }else{ div++; flg = false; } } //ラス1の素因数 res = n; if(prime_factor[prime_factor.size() - 1].first == res){ prime_factor[prime_factor.size() - 1].second++; }else{ prime_factor.push_back(make_pair(res, 1)); } } //エラトステネスの篩 void Eratosthenes(int n){ // prime_bool の添え字と見たい数は一致させたいので、 // prime_boolやprime_numは1つ多く宣言すること。 prime[0] = false; prime[1] = false; for(int i = 2; i < sqrt(n); i++){ if(prime[i]){ for(int j = 0; i * (j + 2) < n; j++){ prime[i *(j + 2)] = false; } } } // 素数をprime_numに記録 rep(i, n){ if(prime[i]) prime_num.push_back(i); } /* int cnt = 0; for(int i = 2; i < n; i++){ if(prime[i]){ cnt++; } } return cnt; */ } //偶奇判定。奇数ならtrue。 bool odd_even(int num){ bool judge; if(num % 2){ judge = true; }else{ judge = false; } return judge; } //aのmod mにおける逆元を計算する long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } // a^n mod を計算する long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } //main関数内でCOMinitを呼んだ後,COMを呼ぶ. // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < TABLEMAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 nCk, nCrのcombinationでも使える long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } long long abs_ll(ll a){ if(a >= 0){ return a; }else{ return -a; } } // 割り算した時に余りが有る時だけ、+1の商を返す。 long long div_one(ll res, ll div){ // res 割られる数、div 割る数 return (res + div - 1)/div; } // Stringの各桁をvectorの配列に入れる。でかい桁が添字0。 template <class X> void StringtoVec(string str, vector<X> &v){ ll num = stoll(str); ll it = str.size() - 1; // 桁を逆にしたい時、下をon //ll it = 0; v.resize(str.size()); while(num){ v[it] = num % 10; num /= 10; it--; //it++; if(it < 0){ cout << "reference error" << endl; break; } } } // nに数を入れるとその約数の一覧をfactor_listに格納する void get_factor_list(ll n){ int div = 1, res; while(n >= div * div){ if(n % div == 0){ res = div; ll tmp = n / res; factor_list.push_back(res); if(tmp != 1) factor_list.push_back(tmp); div++; }else{ div++; } } sort(factor_list.begin(), factor_list.end()); }
a.cc: In function 'void dijkstra()': a.cc:127:24: error: reference to 'map' is ambiguous 127 | minv = map[u][v]; | ^~~ In file included from /usr/include/c++/14/map:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152, from a.cc:1: /usr/include/c++/14/bits/stl_map.h:102:11: note: candidates are: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' 102 | class map | ^~~ a.cc:109:20: note: 'std::vector<std::vector<long long int> > map' 109 | vector<vector<ll>> map; | ^~~ a.cc:128:21: error: 'i' was not declared in this scope 128 | u = i; | ^ a.cc:138:37: error: reference to 'map' is ambiguous 138 | if(color[v] != BLACK && map[u][v] != 0){ | ^~~ /usr/include/c++/14/bits/stl_map.h:102:11: note: candidates are: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' 102 | class map | ^~~ a.cc:109:20: note: 'std::vector<std::vector<long long int> > map' 109 | vector<vector<ll>> map; | ^~~ a.cc:139:27: error: reference to 'map' is ambiguous 139 | if(d[u] + map[u][v] < d[v]){ | ^~~ /usr/include/c++/14/bits/stl_map.h:102:11: note: candidates are: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' 102 | class map | ^~~ a.cc:109:20: note: 'std::vector<std::vector<long long int> > map' 109 | vector<vector<ll>> map; | ^~~ a.cc:140:35: error: reference to 'map' is ambiguous 140 | d[v] = d[u] + map[u][v]; | ^~~ /usr/include/c++/14/bits/stl_map.h:102:11: note: candidates are: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' 102 | class map | ^~~ a.cc:109:20: note: 'std::vector<std::vector<long long int> > map' 109 | vector<vector<ll>> map; | ^~~ a.cc: In function 'int main(int, const char**)': a.cc:166:5: error: reference to 'map' is ambiguous 166 | map.resize(n); | ^~~ /usr/include/c++/14/bits/stl_map.h:102:11: note: candidates are: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' 102 | class map | ^~~ a.cc:109:20: note: 'std::vector<std::vector<long long int> > map' 109 | vector<vector<ll>> map; | ^~~ a.cc:167:17: error: reference to 'map' is ambiguous 167 | rep(i, n) map[i].resize(n); | ^~~ /usr/include/c++/14/bits/stl_map.h:102:11: note: candidates are: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' 102 | class map | ^~~ a.cc:109:20: note: 'std::vector<std::vector<long long int> > map' 109 | vector<vector<ll>> map; | ^~~ a.cc:172:9: error: reference to 'map' is ambiguous 172 | map[a][b] = c; | ^~~ /usr/include/c++/14/bits/stl_map.h:102:11: note: candidates are: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' 102 | class map | ^~~ a.cc:109:20: note: 'std::vector<std::vector<long long int> > map' 109 | vector<vector<ll>> map; | ^~~
s131434479
p03837
C
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef pair<int, pair<int, int>> PP; int main() { int n, m; cin >> n >> m; vector<vector<PP>> r(n, vector<PP>()); vector<vector<int>> l(n, vector<int>(n, INT_MAX)); vector<int> u(m); for(int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; r.at(--a).push_back({--b, {c, i}}); r.at(b).push_back({a, {c, i}}); } priority_queue<PP, vector<PP>, greater<PP>> que; for(int i = 0; i < n; i++) { que.push(PP(i, P(0, -1))); l.at(i).at(i) = 0; while(que.size()) { PP p = que.top(); que.pop(); if(l.at(i).at(p.first) < p.second.first) continue; if(p.second.second >= 0) u.at(p.second.second) = 1; for(auto e : r.at(p.first)) { if(l.at(i).at(e.first) > p.second.first + e.second.first) { que.push( PP(e.first, P(p.second.first + e.second.first, e.second.second))); l.at(i).at(e.first) = p.second.first + e.second.first; } } } } int o = 0; for(int i = 0; i < m; i++) o += u[i]; cout << m - o << endl; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s249578862
p03837
Java
import java.util.*; import java.io.*; //別解:最短経路か判定する部分 //エッジがいずれかの頂点間の最短経路であるかいなかの調べ方を //各エッジについて、全ての出発点と全ての到着点を調べ、その最短経路に使われるか調べる方法 class Edge{ int from, to, cost; public Edge(int from, int to, int cost) { super(); this.from = from; this.to = to; this.cost = cost; } } public class Main { static int mod = (int) 1e9 + 7; static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 }; public static void main(String[] args) { FastScanner fs = new FastScanner(System.in); int n = fs.nextInt(), m = fs.nextInt(); int g[][] = new int[n][n]; int inf = Integer.MAX_VALUE/2; for(int i=0;i<n;i++)for(int j=0;j<n;j++) { if(i==j)g[i][j]=0; else g[i][j] = inf; } Edge[] es = new Edge[m]; for(int i=0;i<m;i++) { int a = fs.nextInt()-1, b = fs.nextInt()-1, c = fs.nextInt(); g[a][b] = g[b][a] = c; es[i] = new Edge(a,b,c); } for(int k=0;k<n;k++) { for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { g[i][j] = Math.min(g[i][j], g[i][k]+g[k][j]); } } } int cnt = 0; for(Edge e : es) { int from = e.from, to = e.to, cost = e.cost; boolean ok = false; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(g[i][j]==g[i][from] + cost + g[to][j])ok = true; else if(g[i][j]==g[i][to] + cost + g[from][j])ok=true; } } if(!ok)cnt++; } System.out.println(cnt); } } //高速なScanner class FastScanner { private BufferedReader reader = null; private StringTokenizer tokenizer = null; public FastScanner(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } public String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public String nextLine() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken("\n"); } public long nextLong() { return Long.parseLong(next()); } public int nextInt() { return Integer.parseInt(next()); } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; }
Main.java:122: error: reached end of file while parsing } ^ 1 error
s159922704
p03837
C++
/*やったぜ。 投稿者:変態糞土方 (8月16日(水)07時14分22秒) 昨日の8月15日にいつもの浮浪者のおっさん(60歳)と先日メールくれた汚れ好きの土方のにいちゃん (45歳)とわし(53歳)の3人で県北にある川の土手の下で盛りあったぜ。 今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、 そこでしこたま酒を飲んでからやりはじめたんや。 3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。 しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。 浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、 先に兄ちゃんがわしの口に糞をドバーっと出して来た。 それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、 3人で出した糞を手で掬いながらお互いの体にぬりあったり、 糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ~~たまらねえぜ。 しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。 浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると けつの穴が糞と小便でずるずるして気持ちが良い。 にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。 糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。 それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、 糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。 やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。 ああ~~早く糞まみれになろうぜ。 岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や 糞まみれでやりたいやつ、至急、メールくれや。 土方姿のまま浣腸して、糞だらけでやろうや。*/ #include "bits/stdc++.h" #include <unordered_set> #define rep(i,n) for(ll i = 0; i < n; i++) typedef long long ll; typedef unsigned long long ull; using namespace std; #define vll vector<vector<long long>> #define vl vector<long long> #define vi vector<int> #define vii vector<vector<int>> #define pb push_back #define pf push_front #define ld long double #define Sort(a) sort(a.begin(),a.end()) #define cSort(a,cmp) sort(a.begin(),a.end(),cmp) #define reSort(a) sort(a.rbegin(), a.rend()) static ll llMAX = numeric_limits<long long>::max(); static int intMAX = numeric_limits<int>::max(); static ll llMIN = numeric_limits<long long>::min(); static int intMIN = numeric_limits<int>::min(); static ll d_5 = 100000; static ll d9_7 = 1000000007; static ll d_9 = 1000000000; template<class T> void Printvector(std::vector<T> a){ int size = a.size(); rep(i,size){ cout<<a[i]<<" "; } cout<<endl; } template<class T> void Printvector(std::vector<std::vector<T>> a){ int size = a.size(); rep(i,size){ int size2=a[i].size(); rep(j,size2){ cout<<a[i][j]<<" "; } cout<<endl; } cout<<endl; } ll digitpower(ll a,ll b){//aのb乗を計算 if(b==1){ return a; }else if(b==0){ return 1; } if(b%2==1){ ll tmp = digitpower(a,(b-1)/2); tmp%=d9_7; tmp*=tmp; tmp%=d9_7; tmp*=a; return (tmp)%d9_7; }else{ ll tmp = digitpower(a,(b)/2); tmp%=d9_7; tmp*=tmp; tmp%=d9_7; return (tmp)%d9_7; } } //cout<<"cout (set(10))"<<std::setprecision(10)<<kilopi<<endl; struct datas{ int cost; int now; vi past; deque<pair<int,int>> edges; }; /*bool cmp(const datas &a, const datas &b) { return a.x < b.x; }*/ int main(void){ int n,m; cin>>n>>m; vii graph(n,vi(n,intMAX/100)); vector<set<int>> nexts(n); rep(i,m){ int a,b,c; cin>>a>>b>>c; a--;b--; graph[a][b]=c; graph[b][a]=c; nexts[a].insert(b); nexts[b].insert(a); } vii washa=graph; rep(k,n)rep(i,n)rep(j,n){ washa[i][j]=min(washa[i][j],washa[i][k]+washa[k][j]); } unordered_set<pair<int,int>> nums; for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ int a1=i;int a2=j; if(a1>a2)swap(a1,a2); if(nums.find({a1,a2})!=nums.end()){ //過去に見た辺に含まれているので continue; } deque<datas> ope; vi costs0(n,intMAX); ope.pb({0,i,costs0,{}}); while(ope.size()>0){ int now = ope.front().now; int nowcost = ope.front().cost; vi costs = ope.front().past; if(costs[now]<nowcost)continue; costs[now]=nowcost; deque<pair<int,int>> edges = ope.front().edges; ope.pop_front(); if(nowcost>washa[i][j])continue; if(now==j){ //今回のゴール for(auto i:edges){ nums.insert(i); } continue; } costs[now]=nowcost; for(int k:nexts[now]){ if(now!=k && graph[now][k]!=intMAX/100){ if(costs[k]>graph[now][k]+nowcost){ int a1=now; int a2=k; if(a1>a2){ swap(a1,a2); } deque<pair<int,int>> tmpe=edges; tmpe.pb({a1,a2}); ope.pb({nowcost+graph[now][k],(int)k,costs,tmpe}); } } } } } } cout<<m-nums.size()<<endl; return 0; }
a.cc: In function 'int main()': a.cc:142:32: error: use of deleted function 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 142 | unordered_set<pair<int,int>> nums; | ^~~~ In file included from /usr/include/c++/14/unordered_set:41, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:189, from a.cc:48: /usr/include/c++/14/bits/unordered_set.h:142:7: note: 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' is implicitly deleted because the default definition would be ill-formed: 142 | unordered_set() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_set.h: At global scope: /usr/include/c++/14/bits/unordered_set.h:142:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33, from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::equal_to<std::pair<int, int> >, std::hash
s463892775
p03837
C++
#include<bits/stdc++.h> using namespace std; void dij(int V, int E, vector<vector<int> >a, int src, vector<bool> &c) { int dist[V] = {INT_MAX}; dist[src] = 0; for (int i = 1; i <= V - 1; i++) { for (int j = 0; j < E; j++) { int u = a[j][0]; int v = a[j][1]; int weight = a[j][2]; if (dist[u] != INT_MAX && dist[u] + weight < dist[v]) { dist[v] = dist[u] + weight; c[j] = true; } } } } int main() { int n, m; cin>>n>>m; vector<vector<int> >a(n, vector<int> (m, 0)); //vector<vector<bool> >vis(n, vector<int> (m, false)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin>>a[i][j]; //memset(vis, false, sizeof(vis)); vector<bool> c(m, false); bellman(n, m, a, 0, c); int res = 0; for(int i = 0; i < m; i++) if(c[i] == false) res++; cout<<res<<"\n"; return 0; }
a.cc: In function 'int main()': a.cc:35:9: error: 'bellman' was not declared in this scope 35 | bellman(n, m, a, 0, c); | ^~~~~~~
s124938191
p03837
C++
#include<bits/stdc++.h> using namespace std; void dij(int V, int E, vector<vector<int> >a, int src, vector<bool> &c) { int dist[V] = {INT_MAX}; dist[src] = 0; for (int i = 1; i <= V - 1; i++) { for (int j = 0; j < E; j++) { int u = a[j][0]; int v = a[j][1]; int weight = a[j][2]; if (dist[u] != INT_MAX && dist[u] + weight < dist[v]) { dist[v] = dist[u] + weight; c[j] = true; } } } } int main() { int n, m; cin>>n>>m; vector<vector<int> >a(n, vector<int> (m, 0)); //vector<vector<bool> >vis(n, vector<int> (m, false)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin>>a[i][j]; //memset(vis, false, sizeof(vis)); vector<bool> c(m, false); bellman(n, m, a, vis, 0, c); int res = 0; for(int i = 0; i < m; i++) if(c[i] == false) res++; cout<<res<<"\n"; return 0; }
a.cc: In function 'int main()': a.cc:35:26: error: 'vis' was not declared in this scope 35 | bellman(n, m, a, vis, 0, c); | ^~~ a.cc:35:9: error: 'bellman' was not declared in this scope 35 | bellman(n, m, a, vis, 0, c); | ^~~~~~~
s540721902
p03837
C++
#include<bits/stdc++.h> using namespace std; void dij(int V, int E, vector<vector<int> >a, int src, vector<bool> &c) { int dist[V] = INT_MAX; dist[src] = 0; for (int i = 1; i <= V - 1; i++) { for (int j = 0; j < E; j++) { int u = a[j][0]; int v = a[j][1]; int weight = a[j][2]; if (dist[u] != INT_MAX && dist[u] + weight < dist[v]) { dist[v] = dist[u] + weight; c[j] = true; } } } } int main() { int n, m; cin>>n>>m; vector<vector<int> >a(n, vector<int> (m, 0)); //vector<vector<bool> >vis(n, vector<int> (m, false)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin>>a[i][j]; //memset(vis, false, sizeof(vis)); vector<bool> c(m, false); bellman(n, m, a, vis, 0, c); int res = 0; for(int i = 0; i < m; i++) if(c[i] == false) res++; cout<<res<<"\n"; return 0; }
a.cc: In function 'void dij(int, int, std::vector<std::vector<int> >, int, std::vector<bool>&)': a.cc:6:23: error: array must be initialized with a brace-enclosed initializer 6 | int dist[V] = INT_MAX; | ^~~~~~~ a.cc: In function 'int main()': a.cc:35:26: error: 'vis' was not declared in this scope 35 | bellman(n, m, a, vis, 0, c); | ^~~ a.cc:35:9: error: 'bellman' was not declared in this scope 35 | bellman(n, m, a, vis, 0, c); | ^~~~~~~
s475956343
p03837
C++
#include<bits/stdc++.h> using namespace std; void dij(int V, int E, vector<vector<int> >a, int src, vector<bool> &c) { int dist[V] = INT_MAX; dist[src] = 0; for (int i = 1; i <= V - 1; i++) { for (int j = 0; j < E; j++) { int u = a[j][0]; int v = a[j][1]; int weight = a[j][2]; if (dist[u] != INT_MAX && dist[u] + weight < dist[v]) { dist[v] = dist[u] + weight; c[j] = true; } } } } int main() { int n, m; cin>>n>>m; vector<vetcor<int> >a(n, vector<int> (m, 0)); //vector<vector<bool> >vis(n, vector<int> (m, false)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin>>a[i][j]; //memset(vis, false, sizeof(vis)); vector<bool> c(m, false); bellman(n, m, a, vis, 0, c); int res = 0; for(int i = 0; i < m; i++) if(c[i] == false) res++; cout<<res<<"\n"; return 0; }
a.cc: In function 'void dij(int, int, std::vector<std::vector<int> >, int, std::vector<bool>&)': a.cc:6:23: error: array must be initialized with a brace-enclosed initializer 6 | int dist[V] = INT_MAX; | ^~~~~~~ a.cc: In function 'int main()': a.cc:28:16: error: 'vetcor' was not declared in this scope 28 | vector<vetcor<int> >a(n, vector<int> (m, 0)); | ^~~~~~ a.cc:28:26: error: template argument 1 is invalid 28 | vector<vetcor<int> >a(n, vector<int> (m, 0)); | ^ a.cc:28:26: error: template argument 2 is invalid a.cc:28:28: error: expected unqualified-id before '>' token 28 | vector<vetcor<int> >a(n, vector<int> (m, 0)); | ^ a.cc:32:22: error: 'a' was not declared in this scope 32 | cin>>a[i][j]; | ^ a.cc:35:23: error: 'a' was not declared in this scope 35 | bellman(n, m, a, vis, 0, c); | ^ a.cc:35:26: error: 'vis' was not declared in this scope 35 | bellman(n, m, a, vis, 0, c); | ^~~ a.cc:35:9: error: 'bellman' was not declared in this scope 35 | bellman(n, m, a, vis, 0, c); | ^~~~~~~
s861927422
p03837
C++
#include<bits/stdc++.h> using namespace std; void dij(int V, int E, vector<vector<int> >a, int src, vector<bool> &c) { int dist[V] = INT_MAX; dist[src] = 0; for (int i = 1; i <= V - 1; i++) { for (int j = 0; j < E; j++) { int u = a[j][0]; int v = a[j][1]; int weight = a[j][2]; if (dist[u] != INT_MAX && dist[u] + weight < dist[v]) { dist[v] = dist[u] + weight; c[j] = true; } } } } int main() { int n, m; cin>>n>>m; vector<vetor<int> >a(n, vector<int> (m, 0)); //vector<vector<bool> >vis(n, vector<int> (m, false)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin>>a[i][j]; //memset(vis, false, sizeof(vis)); vector<bool> c(m, false); bellman(n, m, a, vis, 0, c); int res = 0; for(int i = 0; i < m; i++) if(c[i] == false) res++; cout<<res<<"\n"; return 0; }
a.cc: In function 'void dij(int, int, std::vector<std::vector<int> >, int, std::vector<bool>&)': a.cc:6:23: error: array must be initialized with a brace-enclosed initializer 6 | int dist[V] = INT_MAX; | ^~~~~~~ a.cc: In function 'int main()': a.cc:28:16: error: 'vetor' was not declared in this scope 28 | vector<vetor<int> >a(n, vector<int> (m, 0)); | ^~~~~ a.cc:28:25: error: template argument 1 is invalid 28 | vector<vetor<int> >a(n, vector<int> (m, 0)); | ^ a.cc:28:25: error: template argument 2 is invalid a.cc:28:27: error: expected unqualified-id before '>' token 28 | vector<vetor<int> >a(n, vector<int> (m, 0)); | ^ a.cc:32:22: error: 'a' was not declared in this scope 32 | cin>>a[i][j]; | ^ a.cc:35:23: error: 'a' was not declared in this scope 35 | bellman(n, m, a, vis, 0, c); | ^ a.cc:35:26: error: 'vis' was not declared in this scope 35 | bellman(n, m, a, vis, 0, c); | ^~~ a.cc:35:9: error: 'bellman' was not declared in this scope 35 | bellman(n, m, a, vis, 0, c); | ^~~~~~~
s030424691
p03837
C++
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define REP(i, j, n) for (int i = j; i < (n); ++i) #define SORT(a) sort(a.begin(), a.end()) using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; int n, m; cin >> n >> m; int a[1000], b[1000], c[1000], dist[100][100]; for (int i = 0; i < m; ++i) { cin >> a[i] >> b[i] >> c[i]; a[i]--, b[i]--; } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i == j) dist[i][j] = 0; else dist[i][j] = inf; } } for (int i = 0; i < m; ++i) { dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]); dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]); } for (int k = 0; k < n; ++k) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } } int ans = m; for (int i = 0; i < m; ++i) { bool shortest = false; for (int j = 0; j < n; ++j) if (dist[j][a[i]] + c[i] == dist[j][b[i]]) shortest = true; if (shortest == true) { ans = ans - 1; } } cout << ans << endl; }
a.cc:11:1: error: 'cin' does not name a type 11 | cin >> n >> m; | ^~~ a.cc:13:1: error: expected unqualified-id before 'for' 13 | for (int i = 0; i < m; ++i) | ^~~ a.cc:13:17: error: 'i' does not name a type; did you mean 'vi'? 13 | for (int i = 0; i < m; ++i) | ^ | vi a.cc:13:24: error: expected unqualified-id before '++' token 13 | for (int i = 0; i < m; ++i) | ^~ a.cc:19:1: error: expected unqualified-id before 'for' 19 | for (int i = 0; i < n; ++i) | ^~~ a.cc:19:17: error: 'i' does not name a type; did you mean 'vi'? 19 | for (int i = 0; i < n; ++i) | ^ | vi a.cc:19:24: error: expected unqualified-id before '++' token 19 | for (int i = 0; i < n; ++i) | ^~ a.cc:30:1: error: expected unqualified-id before 'for' 30 | for (int i = 0; i < m; ++i) | ^~~ a.cc:30:17: error: 'i' does not name a type; did you mean 'vi'? 30 | for (int i = 0; i < m; ++i) | ^ | vi a.cc:30:24: error: expected unqualified-id before '++' token 30 | for (int i = 0; i < m; ++i) | ^~ a.cc:36:1: error: expected unqualified-id before 'for' 36 | for (int k = 0; k < n; ++k) | ^~~ a.cc:36:17: error: 'k' does not name a type 36 | for (int k = 0; k < n; ++k) | ^ a.cc:36:24: error: expected unqualified-id before '++' token 36 | for (int k = 0; k < n; ++k) | ^~ a.cc:48:1: error: expected unqualified-id before 'for' 48 | for (int i = 0; i < m; ++i) | ^~~ a.cc:48:17: error: 'i' does not name a type; did you mean 'vi'? 48 | for (int i = 0; i < m; ++i) | ^ | vi a.cc:48:24: error: expected unqualified-id before '++' token 48 | for (int i = 0; i < m; ++i) | ^~ a.cc:60:1: error: 'cout' does not name a type 60 | cout << ans << endl; | ^~~~ a.cc:61:1: error: expected declaration before '}' token 61 | } | ^
s469331010
p03837
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(i,a,b) for(ll i=a;i<b;i++) #define rrep(i,a,b) for(ll i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() #define MAX_V 104 int d[MAX_V][MAX_V]; //d[u][v]は辺e=(u,v)のコスト(存在しない場合はINF,d[i][i]=0) int V; //頂点数 int nex[MAX_V][MAX_V]; //iからjへの最短経路におけるiの1つ後の点 ll path[MAX_V][MAX_V]; void warshall_floyd(){ rep(i, 0, V){ rep(j, 0, V){ nex[i][j] = j; } } for(int k = 0; k < V; k++) for(int i = 0; i < V; i++) for(int j = 0; j < V; j++){ if(d[i][k] + d[k][j] < d[i][j]){ d[i][j] = d[i][k] + d[k][j]; nex[i][j] = nex[i][k]; } } } void print_path(int start, int goal){ for(int cur = start; cur != goal; cur = nex[cur][goal]){ path[cur][nex[cur][goal]] = 1; path[nex[cur][goal]][cur] = 1; } path[cur][nex[cur][goal]] = 1; path[nex[cur][goal]][cur] = 1; } int main(void){ ll n, m; cin >> n >> m; V = n; rep(i, 0, V){ rep(j, 0, V){ path[i][j] = -1; } } rep(i, 0, m){ ll a, b, c; cin >> a >> b >> c; a--; b--; d[a][b] = c; d[b][a] = c; path[a][b] = 0; } warshall_floyd(); rep(i, 0, V){ rep(j, 0, V){ print_path(i, j); } } ll sum = 0; rep(i, 0, V){ rep(j, 0, V){ if(path[i][j] == 0){ sum++; } } } cout << sum << endl; return 0; }
a.cc: In function 'void print_path(int, int)': a.cc:38:10: error: 'cur' was not declared in this scope 38 | path[cur][nex[cur][goal]] = 1; | ^~~
s060040617
p03837
C++
int main(void){ 2 const int inf = 100000000; 3 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 int n,m; cin>>n>>m; int a[1000],b[1000],c[1000],dist[100][100]; for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--; } for(inti=0;i< for(int j = 0; m; ++i){ b[i] >> c[i]; n; ++i){ j<n;++j){ } } if(i==j) dist[i][j]=0; else dist[i][j]=inf; for(inti=0;i<m;++i){ dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]); dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]); } for(intk=0;k<n;++k){ for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j){ dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]); } } } int ans=m; for(inti=0;i<m;++i){ bool shortest=false; for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true; if(shortest==true){ ans=ans-1; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:2:2: error: expected ';' before 'const' 2 | 2 const int inf = 100000000; | ^~~~~~ | ; a.cc:3:3: error: expected ';' before numeric constant 3 | 3 | ^ | ; 4 | 3 4 5 6 7 8 9 | ~ a.cc:6:10: error: 'cin' was not declared in this scope 6 | int n,m; cin>>n>>m; | ^~~ a.cc:6:15: error: 'n' was not declared in this scope 6 | int n,m; cin>>n>>m; | ^ a.cc:6:18: error: 'm' was not declared in this scope 6 | int n,m; cin>>n>>m; | ^ a.cc:8:5: error: 'inti' was not declared in this scope; did you mean 'int'? 8 | for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--; | ^~~~ | int a.cc:8:12: error: 'i' was not declared in this scope 8 | for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--; | ^ a.cc:9:1: error: expected primary-expression before '}' token 9 | } | ^ a.cc:8:44: error: expected ')' before '}' token 8 | for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--; | ~ ^ | ) 9 | } | ~ a.cc:9:1: error: expected primary-expression before '}' token 9 | } | ^ a.cc: At global scope: a.cc:10:1: error: expected unqualified-id before 'for' 10 | for(inti=0;i< for(int j = 0; | ^~~ a.cc:10:12: error: 'i' does not name a type 10 | for(inti=0;i< for(int j = 0; | ^ a.cc:11:1: error: 'm' does not name a type 11 | m; ++i){ | ^ a.cc:11:4: error: expected unqualified-id before '++' token 11 | m; ++i){ | ^~
s148317178
p03837
C++
#include <bits/stdc++.h> #include <iostream> #include <algorithm> using namespace std; int main(){ int n,m,a[1000],b[1000],c[1000],dist[100][100],ans =0; cin >> n>> m; for(int i=0;i<m;i++){ cin >> a[i] >> b[i] >> c[i]; a[i]--,b[i]--; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i==j){ dist[i][j] = 0; } else{ dist[i][j] = 1e9; } } } for(int i=0;i<m;i++){ dist[a[i]][b[i]] = min(dist[a[i]][b[i]],c[i]); dist[b[i]][a[i]] = min(dist[b[i]][a[i]],c[i]); } for (int k = 0; k < n; k++){ for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } for(int i=0;i<m;i++){ bool ant = false; for(int j=0;j<n;j++){ if(dist[j][a[i]] ==dist[a[i]][b[i]]-c[i]){ ant = true; } if(ant){ ans++; } } } cout << m-ans << endl; }
a.cc: In function 'int main()': a.cc:42:9: error: 'd' was not declared in this scope 42 | d[i][j] = min(d[i][j], d[i][k] + d[k][j]); | ^
s618204003
p03837
C++
#include <iostream> using namespace std ; int a[40], b[40], c[40]; int n, ma, mb; int main(void){ cin>>n; cin>>ma; cin>>mb; for(int i=0;i<n;i++){ cin>>a[i]; cin>>b[i]; cin>>c[i]; } int ans=search(0, 0, 0, 0); if(ans==10000) ans=-1; cout<<ans; } int search(int sumA, int sumB, int sumC, int st){ if(st==n-1){ if(sumA*mb==sumB*ma && sumA!=0) return sumC; else if((sumA+a[n-1])*mb==(sumB+b[n-1]*ma)) return sumC+c[n-1]; else return 10000; } return min(search(sumA+a[st], sumB+b[st], sumC+c[st], st+1), search(sumA, sumB, sumC, st+1)); }
a.cc: In function 'int main()': a.cc:17:19: error: no matching function for call to 'search(int, int, int, int)' 17 | int ans=search(0, 0, 0, 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:2332:5: note: candidate: 'template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> _ForwardIterator1 std::search(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _BinaryPredicate)' 2332 | search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | ^~~~~~ /usr/include/c++/14/bits/stl_algobase.h:2332:5: note: candidate expects 5 arguments, 4 provided
s791304517
p03837
C++
#include <cstdio> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; const int INF=1<<29; int main(){ int n,m,a[100],b[100],c[100]; scanf("%d%d",&n,&m); rep(i,m) scanf("%d%d%d",&a[i],&b[i],&c[i]), a[i]--, b[i]--; int d[100][100]; rep(u,n) rep(v,n) d[u][v]=d[v][u]=(u==v?0:INF); rep(i,m) d[a[i]][b[i]]=d[b[i]][a[i]]=c[i]; rep(k,n) rep(i,n) rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]); int ans=0; rep(i,m) if(c[i]>d[a[i]][b[i]]) ans++; printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:18:44: error: 'min' was not declared in this scope; did you mean 'main'? 18 | rep(k,n) rep(i,n) rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]); | ^~~ | main
s852126428
p03837
C++
#![allow(unused_imports)] #![allow(non_snake_case)] #![allow(unused_mut)] #![allow(dead_code)] #![allow(unused_variables)] use std::collections::HashSet; use std::collections::HashMap; use std::collections::BTreeSet; use std::collections::VecDeque; use std::cmp::{max, min}; use std::mem::swap; use std::io::prelude::*; // input() fn input<T>() -> T where T: std::str::FromStr { let stdin = std::io::stdin(); let token: String = stdin .lock() .bytes() .map(|c| c.unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().unwrap() } static INF: usize = 100_000; fn main() { let n = input::<usize>(); let m = input::<usize>(); let abc = (0..m) .map(|_| (input::<usize>()-1,input::<usize>()-1,input::<usize>())) .collect::<Vec<_>>(); let mut d = vec![vec![INF; 100]; 100]; for i in 0..n { d[i][i] = 0; } for &(a, b, c) in &abc { d[a][b] = min(d[a][b], c); d[b][a] = min(d[b][a], c); } for i in 0..n { for j in 0..n { for k in 0..n { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } let mut ans = m; for &(a, b, c) in &abc { let shortest = || { for j in 0..n { if d[j][a] + c == d[j][b] { return true; } } false }; if shortest() { ans-=1; } } println!("{}", ans); }
a.cc:1:2: error: invalid preprocessing directive #! 1 | #![allow(unused_imports)] | ^ a.cc:2:2: error: invalid preprocessing directive #! 2 | #![allow(non_snake_case)] | ^ a.cc:3:2: error: invalid preprocessing directive #! 3 | #![allow(unused_mut)] | ^ a.cc:4:2: error: invalid preprocessing directive #! 4 | #![allow(dead_code)] | ^ a.cc:5:2: error: invalid preprocessing directive #! 5 | #![allow(unused_variables)] | ^ a.cc:32:16: error: too many decimal points in number 32 | let abc = (0..m) | ^~~~ a.cc:37:14: error: too many decimal points in number 37 | for i in 0..n { | ^~~~ a.cc:44:14: error: too many decimal points in number 44 | for i in 0..n { | ^~~~ a.cc:45:18: error: too many decimal points in number 45 | for j in 0..n { | ^~~~ a.cc:46:22: error: too many decimal points in number 46 | for k in 0..n { | ^~~~ a.cc:56:22: error: too many decimal points in number 56 | for j in 0..n { | ^~~~ a.cc:7:1: error: 'use' does not name a type 7 | use std::collections::HashSet; | ^~~ a.cc:8:1: error: 'use' does not name a type 8 | use std::collections::HashMap; | ^~~ a.cc:9:1: error: 'use' does not name a type 9 | use std::collections::BTreeSet; | ^~~ a.cc:10:1: error: 'use' does not name a type 10 | use std::collections::VecDeque; | ^~~ a.cc:11:1: error: 'use' does not name a type 11 | use std::cmp::{max, min}; | ^~~ a.cc:12:1: error: 'use' does not name a type 12 | use std::mem::swap; | ^~~ a.cc:13:1: error: 'use' does not name a type 13 | use std::io::prelude::*; // input() | ^~~ a.cc:15:1: error: 'fn' does not name a type 15 | fn input<T>() -> T | ^~ a.cc:27:11: error: found ':' in nested-name-specifier, expected '::' 27 | static INF: usize = 100_000; | ^ | :: a.cc:27:8: error: 'INF' does not name a type 27 | static INF: usize = 100_000; | ^~~ a.cc:29:1: error: 'fn' does not name a type 29 | fn main() { | ^~
s879383950
p03837
C++
#![allow(unused_imports)] #![allow(non_snake_case)] #![allow(unused_mut)] #![allow(dead_code)] #![allow(unused_variables)] use std::collections::HashSet; use std::collections::HashMap; use std::collections::BTreeSet; use std::collections::VecDeque; use std::cmp::{max, min}; use std::mem::swap; use std::io::prelude::*; // input() fn input<T>() -> T where T: std::str::FromStr { let stdin = std::io::stdin(); let token: String = stdin .lock() .bytes() .map(|c| c.unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().unwrap() } fn main() { let n = input::<usize>(); let m = input::<usize>(); let abc = (0..n) .map(|_| (input::<usize>()-1,input::<usize>()-1,input::<usize>())) .collect::<Vec<_>>(); let mut d = vec![vec![usize::max_value(); 100]; 100]; for i in 0..n { d[i][i] = 0; } for &(a, b, c) in &abc { d[a][b] = min(d[a][b], c); d[b][a] = min(d[b][a], c); } for i in 0..n { for j in 0..n { for k in 0..n { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } let mut ans = m; for &(a, b, c) in &abc { let shortest = || { for j in 0..n { if d[j][a] + c == d[j][b] { return true; } } false }; if shortest() { ans-=1; } } println!("{}", ans); }
a.cc:1:2: error: invalid preprocessing directive #! 1 | #![allow(unused_imports)] | ^ a.cc:2:2: error: invalid preprocessing directive #! 2 | #![allow(non_snake_case)] | ^ a.cc:3:2: error: invalid preprocessing directive #! 3 | #![allow(unused_mut)] | ^ a.cc:4:2: error: invalid preprocessing directive #! 4 | #![allow(dead_code)] | ^ a.cc:5:2: error: invalid preprocessing directive #! 5 | #![allow(unused_variables)] | ^ a.cc:30:16: error: too many decimal points in number 30 | let abc = (0..n) | ^~~~ a.cc:35:14: error: too many decimal points in number 35 | for i in 0..n { | ^~~~ a.cc:44:14: error: too many decimal points in number 44 | for i in 0..n { | ^~~~ a.cc:45:18: error: too many decimal points in number 45 | for j in 0..n { | ^~~~ a.cc:46:22: error: too many decimal points in number 46 | for k in 0..n { | ^~~~ a.cc:56:22: error: too many decimal points in number 56 | for j in 0..n { | ^~~~ a.cc:7:1: error: 'use' does not name a type 7 | use std::collections::HashSet; | ^~~ a.cc:8:1: error: 'use' does not name a type 8 | use std::collections::HashMap; | ^~~ a.cc:9:1: error: 'use' does not name a type 9 | use std::collections::BTreeSet; | ^~~ a.cc:10:1: error: 'use' does not name a type 10 | use std::collections::VecDeque; | ^~~ a.cc:11:1: error: 'use' does not name a type 11 | use std::cmp::{max, min}; | ^~~ a.cc:12:1: error: 'use' does not name a type 12 | use std::mem::swap; | ^~~ a.cc:13:1: error: 'use' does not name a type 13 | use std::io::prelude::*; // input() | ^~~ a.cc:15:1: error: 'fn' does not name a type 15 | fn input<T>() -> T | ^~ a.cc:27:1: error: 'fn' does not name a type 27 | fn main() { | ^~
s137313956
p03837
C++
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) const double PI = acos(-1); const double EPS = 1e-15; long long INF=(long long)1E17; #define i_7 (long long)(1E9+7) long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } using namespace std; bool prime_(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd_(long long a, long long b){ if(a<b){ swap(a,b); } if(a%b==0){ return b; }else{ return gcd_(b,a%b); } } long long lcm_(long long x, long long y){ return (x/gcd_(x,y))*y; } class UnionFind { public: //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。 vector<int> Parent; //クラスを作るときは、Parentの値を全て-1にする。 //以下のようにすると全てバラバラの頂点として解釈できる。 UnionFind(int N) { Parent = vector<int>(N, -1); } //Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)];//先祖をrootで取っておきたい。 } //AとBをくっ付ける bool connect(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらAとBをひっくり返す。 if (size(A) < size(B)) swap(A, B); //Aのサイズを更新する Parent[A] += Parent[B]; //Bの親をAに変更する Parent[B] = A; return true; } }; int main(){ int n,m; cin>>n>>m; vector<int> dist(n, vector<int>(n, 10'000'000)); REP(i,n){ dist[i][i] = 0; } int a[m],b[m],c[m]; REP(i,m){ cin>>a[i]>>b[i]>>c[i]; a[i]--;b[i]--; dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i]; } REP(k,n){ REP(i,n){ REP(j,n){ dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]); } } } int ans=0; bool flag; REP(i,m){ flag = false; REP(s,n){ REP(t,n){ if(dist[s][t]==dist[s][a[i]]+c[i]+dist[b[i]][t] || dist[s][t]==dist[s][b[i]]+c[i]+dist[a[i]][t]){ flag = true; break; } } if(flag)break; } if(flag)ans++; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:93:49: error: no matching function for call to 'std::vector<int>::vector(int&, std::vector<int>)' 93 | vector<int> dist(n, vector<int>(n, 10'000'000)); | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Alloc = std::allocator<int>]' 707 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed: a.cc:93:49: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>') 93 | vector<int> dist(n, vector<int>(n, 10'000'000)); | ^ /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>]' 678 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>' 678 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>; std::__type_identity_t<_Alloc> = std::allocator<int>]' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ~~~~~~~~~^~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>; std::false_type = std::false_type]' 640 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>; std::true_type = std::true_type]' 635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>; std::__type_identity_t<_Alloc> = std::allocator<int>]' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 620 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 601 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int; value_type = int; allocator_type = std::allocator<int>]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<int>::value_type&' {aka 'const int&'} 569 | vector(size_type __n, const value_type& __value, | ~~~~~~~~~~~~~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int; allocator_type = std::allocator<int>]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<int>::allocator_type&' {aka 'const std::allocator<int>&'} 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>]' 542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = std::allocator<int>]' 531 | vector() = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided a.cc:95:12: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 95 | dist[i][i] = 0; | ^ a.cc:101:15: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 101 | dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i]; | ^ a.cc:101:34: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 101 | dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i]; | ^ a.cc:106:16: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 106 | dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]); | ^ a.cc:106:33: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 106 | dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]); | ^ a.cc:106:45: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 106 | dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]); | ^ a.cc:106:56: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 106 | dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]); | ^ a.cc:117:19: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 117 | if(dist[s][t]==dist[s][a[i]]+c[i]+dist[b[i]][t] || dist[s][t]==dist[s][b[i]]+c[i]+dist[a[i]][t]){ | ^ a.cc:117:31: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 117 | if(dist[s][t]==dist[s][a[i]]+c[i]+dist[b[i]][t] || dist[s][t]==dist[s][b[i]]+c[i]+dist[a[i]][t]){ | ^ a.cc:117:53: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 117 | if(dist[s][t]==dist[s][a[i]]+c[i]+dist[b[i]][t] || dist[s][t]==dist[s][b[i]]+c[i]+dist[a[i]][t]){ | ^ a.cc:117:67: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 117 | if(dist[s][t]==dist[s][a[i]]+c[i]+dist[b[i]][t] || dist[s][t]==dist[s][b[i]]+c[i]+dist[a[i]][t]){ | ^ a.cc:117:79: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 117 | if(dist[s][t]==dist[s][a[i]]+c[i]+dist[b[i]][t] || dist[s][t]==dist[s][b[i]]+c[i]+dist[a[i]][t]){ | ^ a.cc:117:101: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 117 | if(dist[s][t]==dist[s][a[i]]+c[i]+dist[b[i]][t] || dist[s][t]==dist[s][b[i]]+c[i]+dist[a[i]][t]){ | ^
s396275323
p03837
C++
from collections import defaultdict from heapq import heappop, heappush class Graph(object): """ 隣接リストによる有向グラフ """ def __init__(self): self.graph = defaultdict(list) def __len__(self): return len(self.graph) def add_edge(self, src, dst, weight=1): self.graph[src].append((dst, weight)) def get_nodes(self): return self.graph.keys() class Dijkstra(object): """ ダイクストラ法(二分ヒープ)による最短経路探索 計算量: O((E+V)logV) """ def __init__(self, graph, start): self.g = graph.graph # startノードからの最短距離 # startノードは0, それ以外は無限大で初期化 self.dist = defaultdict(lambda: float('inf')) self.dist[start] = 0 # 最短経路での1つ前のノード self.prev = defaultdict(lambda: None) # startノードをキューに入れる self.Q = [] heappush(self.Q, (self.dist[start], start)) while self.Q: # 優先度(距離)が最小であるキューを取り出す dist_u, u = heappop(self.Q) if self.dist[u] < dist_u: continue for v, weight in self.g[u]: alt = dist_u + weight if self.dist[v] > alt: self.dist[v] = alt self.prev[v] = u heappush(self.Q, (alt, v)) def shortest_distance(self, goal): """ startノードからgoalノードまでの最短距離 """ return self.dist[goal] def shortest_path(self, goal): """ startノードからgoalノードまでの最短経路 """ path = [] node = goal while node is not None: path.append(node) node = self.prev[node] return path[::-1] def solve(): n,m = (int(i) for i in input().split()) route = Graph() tmp = [[0]*n for _ in range(n)] for i in range(m): a,b,c = (int(i) for i in input().split()) route.add_edge(a-1,b-1,c) route.add_edge(b-1,a-1,c) tmp[a-1][b-1] = 1 for i in range(n): for j in range(n): if not i== j: #iを始点としてjに着く経路 ds = Dijkstra(route,i) query = ds.shortest_path(j) for k in range(len(query)-1): tmp[query[k]][query[k+1]] = 0 ans = 0 for i in range(n): ans += sum(tmp[i]) print(ans) solve()
a.cc:4:7: warning: missing terminating " character 4 | """ | ^ a.cc:4:7: error: missing terminating " character a.cc:6:7: warning: missing terminating " character 6 | """ | ^ a.cc:6:7: error: missing terminating " character a.cc:22:7: warning: missing terminating " character 22 | """ | ^ a.cc:22:7: error: missing terminating " character a.cc:25:7: warning: missing terminating " character 25 | """ | ^ a.cc:25:7: error: missing terminating " character a.cc:30:11: error: invalid preprocessing directive #start\U000030ce\U000030fc\U000030c9\U0000304b\U00003089\U0000306e\U00006700\U000077ed\U00008ddd\U000096e2 30 | # startノードからの最短距離 | ^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:31:11: error: invalid preprocessing directive #start\U000030ce\U000030fc\U000030c9\U0000306f0 31 | # startノードは0, それ以外は無限大で初期化 | ^~~~~~~~~~~~~~ a.cc:32:47: warning: multi-character character constant [-Wmultichar] 32 | self.dist = defaultdict(lambda: float('inf')) | ^~~~~ a.cc:35:11: error: invalid preprocessing directive #\U00006700\U000077ed\U00007d4c\U00008def\U00003067\U0000306e1\U00003064\U0000524d\U0000306e\U000030ce\U000030fc\U000030c9 35 | # 最短経路での1つ前のノード | ^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:38:11: error: invalid preprocessing directive #start\U000030ce\U000030fc\U000030c9\U00003092\U000030ad\U000030e5\U000030fc\U0000306b\U00005165\U0000308c\U0000308b 38 | # startノードをキューに入れる | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:43:15: error: invalid preprocessing directive #\U0000512a\U00005148\U00005ea6\U0000ff08\U00008ddd\U000096e2\U0000ff09\U0000304c\U00006700\U00005c0f\U00003067\U00003042\U0000308b\U000030ad\U000030e5\U000030fc\U00003092\U000053d6\U0000308a\U000051fa\U00003059 43 | # 優先度(距離)が最小であるキューを取り出す | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:55:11: warning: missing terminating " character 55 | """ | ^ a.cc:55:11: error: missing terminating " character a.cc:57:11: warning: missing terminating " character 57 | """ | ^ a.cc:57:11: error: missing terminating " character a.cc:61:11: warning: missing terminating " character 61 | """ | ^ a.cc:61:11: error: missing terminating " character a.cc:63:11: warning: missing terminating " character 63 | """ | ^ a.cc:63:11: error: missing terminating " character a.cc:86:10: error: invalid preprocessing directive #i\U00003092\U000059cb\U000070b9\U00003068\U00003057\U00003066j\U0000306b\U00007740\U0000304f\U00007d4c\U00008def 86 | #iを始点としてjに着く経路 | ^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:1:1: error: 'from' does not name a type 1 | from collections import defaultdict | ^~~~
s643360078
p03837
C++
#include <bits/stdc++.h> #define l_ength size const int inf = 1000000; using ll = long long; using namespace std; struct edge{ int from; int to; int cost; }; int main(){ int n, m; cin >> n >> m; int dist[n][n]; vector<edge> graph; for( int i = 0; i < n; ++i ){ for( int j = 0; j < n; ++j ){ dist[i][j] = ( i == j ) ? 0 : INF; } } for( int i = 0; i < m; ++i ){ int a, b, c; cin >> a >> b >> c; --a; --b; dist[a][b] = dist[b][a] = c; graph.push_back( ( edge ){ a, b, c } ); } for( int k = 0; k < n; ++k ){ for( int i = 0; i < n; ++i ){ for( int j = 0; j < n; ++j ){ /* ここで inf の足し算が行われることに注意 1<<30 のとき inf+inf == 1<<31 でオーバーフローする */ dist[i][j] = min( dist[i][j], dist[i][k]+dist[k][j] ); } } } /* 使われない辺の必要条件: 辺 s → t について,d(s, t) < c(s, t) (⇔ その辺を使わない最短経路がある) この必要条件に入らない辺については d(s, t) = c(s, t) となるが,これは s → t のルートでこの辺を使うことを示している よって「ある辺が使われる ⇔ d(s, t) = c(s, t) 」が成り立ち,これをチェックすれば O(M) で計算できる */ int ans = 0; for( auto e : graph ) if( d[e.from][e.to] < e.cost ) ++ans; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:55: error: 'INF' was not declared in this scope 19 | dist[i][j] = ( i == j ) ? 0 : INF; | ^~~ a.cc:44:35: error: 'd' was not declared in this scope 44 | for( auto e : graph ) if( d[e.from][e.to] < e.cost ) ++ans; | ^
s898488250
p03837
C++
#include <bits/stdc++.h> #define l_ength size using ll = long long; const int inf = 1000000; const int mod = 1000000007; using namespace std; struct edge{ int from; int to; int cost; }; int main(){ int n, m; cin >> n >> m; int dist[n][n]; vector<edge> graph; for( int i = 0; i < n; ++i ){ for( int j = 0; j < n; ++j ){ dist[i][j] = ( i == j ) ? 0 : infll; } } for( int i = 0; i < m; ++i ){ int a, b, c; cin >> a >> b >> c; --a; --b; dist[a][b] = dist[b][a] = c; graph.push_back( ( edge ){ a, b, c } ); } for( int k = 0; k < n; ++k ){ for( int i = 0; i < n; ++i ){ for( int j = 0; j < n; ++j ){ dist[i][j] = min( dist[i][j], dist[i][k]+dist[k][j] ); } } } int ans = 0; for( auto e : graph ){ bool flag = false; for( int i = 0; i < n; ++i ){ for( int j = i+1; j < n; ++j ){ // この条件は「i → j の最短距離に辺 e が使われる」と同値 if( dist[i][e.from]+e.cost+dist[e.to][j] == dist[i][j] || dist[i][e.to]+e.cost+dist[e.from][j] == dist[i][j] ){ flag = true; } } } if( !flag ) ++ans; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:55: error: 'infll' was not declared in this scope; did you mean 'inf'? 20 | dist[i][j] = ( i == j ) ? 0 : infll; | ^~~~~ | inf
s741124287
p03837
C++
#include <bits/stdc++.h> #define l_ength size using ll = long long; using namespace std; const int inf = 1000000; struct edge{ int from; int to; int cost; }; int main(){ int n, m; cin >> n >> m; int dist[n][n]; vector<edge> graph; for( int i = 0; i < n; ++i ){ for( int j = 0; j < n; ++j ){ dist[i][j] = INF; } } for( int i = 0; i < n; ++i ) dist[i][i] = 0; for( int i = 0; i < m; ++i ){ int a, b, c; cin >> a >> b >> c; --a; --b; dist[a][b] = dist[b][a] = c; graph.push_back( ( edge ){ a, b, c } ); } for( int k = 0; k < n; ++k ){ for( int i = 0; i < n; ++i ){ for( int j = 0; j < n; ++j ){ dist[i][j] = min( dist[i][j], dist[i][k]+dist[k][j] ); } } } int ans = 0; for( auto e : graph ){ bool flag = false; for( int i = 0; i < n; ++i ){ for( int j = i+1; j < n; ++j ){ // この条件は「i → j の最短距離に辺 e が使われる」と同値 if( dist[i][e.from]+e.cost+dist[e.to][j] == dist[i][j] ){ flag = true; goto endloop; } } } endloop: if( !flag ) ++ans; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:38: error: 'INF' was not declared in this scope 19 | dist[i][j] = INF; | ^~~
s644232022
p03837
C++
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> P; const int INF = pow(10, 7); int main(){ int n, m;cin>>n>>m; vector<vector<int>> dis(n, vector<int>(n, INF)); vector<pair<P, int>> edge(m); for(int i=0;i<m;i++){ int a, b, c;cin>>a>>b>>c;a--;b--; dis[a][b]=dis[b][a]=c; edge[i]=make_pair(P(a, b), c); } for(int i=0;i<n;i++)dis[i][i]=0; for(int k=0;i<n;k++){ for(int i=0;j<n;i++){ for(int j=0;k<n;j++){ if(dis[i][k]==INF || dis[k][j]==INF)continue; dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j]); } } } int ans=m; for(int i=0;i<m;i++){ bool used=false; for(int j=0;j<n;j++){ if(dis[j][edge[i].first.first]==dis[j][edge[i].first.second]+edge[i].second)used=true; } if(used)ans--; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:16:15: error: 'i' was not declared in this scope 16 | for(int k=0;i<n;k++){ | ^ a.cc:17:21: error: 'j' was not declared in this scope 17 | for(int i=0;j<n;i++){ | ^
s115989956
p03837
C++
#include<bits/stdc++.h> using namespace std; int inf = 10000001; int main(){ int n, m;cin >> n >> m; vector<int> a(m); vector<int> b(m); vector<int> c(m); vector<vector<int> > dp(n+1, vector<int>(n+1)); for(int i = 0; i<m;i++){ cin >> a[i] >> b[i] >> c[i]; a[i]--;b[i]-- } for(int i = 0; i<n;i++){ for(int l = 0; l < n; l++){ if(i == l){dp[i][l] = 0;} else{dp[i][l] = inf;} } } for(int i = 0; i<m;i++){ dp[a[i]][b[i]] = c[i]; dp[b[i]][a[i]] = c[i]; } for(int k = 0; k<n;k++){ for(int i = 0; i<n;i++){ for(int l = 0; l<n; l++){ dp[i][l] = min(dp[i][l], dp[i][k]+dp[k][l]); } } } int ans = n; int j = 0; for(int i = 0; i<m; i++){ j = 0; for(int l = 0; l<n; l++){ if(dp[l][a[i]] + c[i] == dp[l][b[i]]){j = 1;} } if(j == 1){ans--;} } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:14:22: error: expected ';' before '}' token 14 | a[i]--;b[i]-- | ^ | ; 15 | } | ~
s161089653
p03837
C++
#include <iostream> #include <algorithm> #include <vector> #include <queue> using namespace std; template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;} bool used[100][100]; // O(V^3) void warshall_floyd(int n, vector<vector<int> > &g) { for(int k = 0; k < n; ++k) for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) { if(chmin(g[i][j], g[i][k] + g[k][j])) { used[i][j] = false; used[i][k] = true; used[k][j] = true; } } } int main() { cin.tie(0); ios_base::sync_with_stdio(false); ll n,m; cin >> n >> m; vector<vector<int> > g(n,vector<int>(n,1e9)); int as[100], bs[100]; for(int i=0; i < m; ++i){ int a,b,c; cin >> a >> b >> c; --a; --b; g[a][b] = c; g[b][a] = c; as[i] = a; bs[i] = b; } warshall_floyd(n, g); int ans = 0; for(int i=0; i < m; ++i) { if(!used[as[i]][bs[i]]) ++ans; } cout << ans << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:27:5: error: 'll' was not declared in this scope 27 | ll n,m; cin >> n >> m; | ^~ a.cc:27:20: error: 'n' was not declared in this scope 27 | ll n,m; cin >> n >> m; | ^ a.cc:27:25: error: 'm' was not declared in this scope; did you mean 'tm'? 27 | ll n,m; cin >> n >> m; | ^ | tm
s822172549
p03837
C++
#include <iostream> #include <algorithm> #include <vector> #include <map> using namespace std; void warshall_floyd(int n, vector<vector<int> > &g) { for(int k = 0; k < n; ++k) for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); ll n,m; cin >> n >> m; vector<vector<int> > g(n,vector<int>(n)); map<pair<int,int>,int> mp; for(int i=0; i < m; ++i){ int a,b,c; cin >> a >> b >> c; --a; --b; g[a][b] = c; g[b][a] = c; mp[make_pair(a,b)] = c; } warshall_floyd(n, g); int ans = 0; for(auto itr = mp.begin(); itr != mp.end(); ++itr) { if(g[itr->first.first][itr->first.second] != itr->second) ++ans; } cout << ans << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:15:5: error: 'll' was not declared in this scope 15 | ll n,m; cin >> n >> m; | ^~ a.cc:15:20: error: 'n' was not declared in this scope 15 | ll n,m; cin >> n >> m; | ^ a.cc:15:25: error: 'm' was not declared in this scope; did you mean 'tm'? 15 | ll n,m; cin >> n >> m; | ^ | tm
s023691051
p03837
C++
#include"bits/stdc++.h" #define int long long #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=(a);i<(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i) #define All(x) (x).begin(),(x).end() #define gridif(a,x,b) if((a)<=(x)&&(x)<(b)) using namespace std; typedef pair<int,int> P; const int mod=1000000007; int digitsum(int n,int b){ if(b<2) return -1; if(n<b) return n; return digitsum(n/b,b)+n%b; } int mpow(int a,int x); int m_inv(int n); vector<int> split(int n,int a); string xal_number(int n,int x); int gcd(int x,int y){return y?gcd(y,x%y):x;} int lcm(int x,int y){return x*y/gcd(x,y);} class Factorial{ private: vector<int> fac; public: Factorial(int N){ fac.push_back(1); rep(i,N) fac.push_back(fac[i]*(i+1)%mod); } int fact(int a){return fac[a];} int ifac(int a){return m_inv(fac[a]);} int cmb(int n,int r); }; struct UnionFind { vector<int> par; // 親ノード UnionFind(int n = 1) { init(n);} void init(int n = 1) { par.resize(n); rep(i,n) par[i] = -1; } int root(int x) { if (par[x] <0) return x; else return par[x] = root(par[x]); } int size(int x){ return -par[root(x)];} bool issame(int x, int y) {return root(x)==root(y);} bool connect(int x, int y); }; signed main(){ int N,M; cin>>N>>M; int INF=1<<29; vector<int> a(M),b(M),c(M); vector<vector<int>> dist(N,vector<int>(N,INF)); rep(i,M){ cin>>a[i]>>b[i]>>c[i]; a[i]--;b[i]--; dist[a[i]][b[i]]=c[i]; dist[b[i]][a[i]]=c[i]; } rep(k,N) rep(i,N) rep(j,N){ if(dist[i][j]>dist[i][k]+dist[k][j]) dist[i][j]=dist[i][k]+dist[k][j]; } int ans=M; rep(i,M){ bool shortest=false; rep(j,n) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true; if(shortest) ans--; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:72:23: error: 'n' was not declared in this scope 72 | rep(j,n) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true; | ^ a.cc:5:38: note: in definition of macro 'repi' 5 | #define repi(i,a,b) for(int i=(a);i<(b);++i) | ^ a.cc:3:39: note: in expansion of macro '_rep' 3 | #define _overload3(_1,_2,_3,name,...) name | ^~~~ a.cc:72:17: note: in expansion of macro 'rep' 72 | rep(j,n) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true; | ^~~
s527750949
p03837
C++
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) using namespace std; typedef long long int ll; typedef pair<int,int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; #define dame { puts("-1"); return 0;} #define yn {puts("Yes");}else{puts("No");} const int INF = 100100100; const int MAX_V = 1100; int cost[MAX_V][MAX_V]; int d[MAX_V]; bool used[MAX_V]; int V; int previ[MAX_V]; void dijkstra(int s){ fill(d, d+V, INF); fill(used, used+V, false); fill(previ, previ+V, -1); d[s] = 0; while(true){ int v = -1; rep(u,V){ if(!used[u] && (v==-1 || d[u]<d[v]))v=u; } if(v==-1)break; used[v] = true; for(int u=0;u<V;u++){ if(d[u]>d[v]+cost[v][u]){ d[u] = d[v] + cost[v][u]; previ[u] = v; } } } } vector<int> get_path(int t){ vector<int> path; for(;t!=-1;t=previ[t])path.push_back(t); reverse(path.begin(), path.end()); return path; } int main() { cin >> V; rep(i,V){ rep(j,V){ if(i==j){ cost[i][j] = 0; }else{ cost[i][j] = INF; } } } int E; rep(i,E){ int from,to,c; cin >> from >> to >> c; from--; to--; cost[from][to] = c; cost[to][from] = c; } flag[V][V]; rep(i,V){ rep(j,V){ flag[i][j] = 0; } } rep(i,V){ dijkstra(i); rep(j,V){ vi v = get_path(j); int from = i; rep(k,v.size()){ flag[from][v[k]] = 1; from = v[k]; } } } int ans = 0; rep(i,V){ rep(j,V){ if(i!=j && cost[i][j]!=INF){ if(flag[i][j]==0)ans++; } } } cout << ans/2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:75:5: error: 'flag' was not declared in this scope 75 | flag[V][V]; | ^~~~
s143630482
p03837
C++
#include "bits/stdc++.h" using namespace std; #define rep(i,a,n) for(int i=a;i<n;i++) #define ALL(s) s.begin(),s.end() const int M=100010; int INF=1000000007; using ll=long long; int main(){ int n,m; int a[110],b[110],c[110]; cin>>n>>m; int dis[110][110]={}; //ワーシャルフロイド法; rep(i,0,n){ rep(j,0,n){ if(i!=j)dis[i][j]=dis[j][i]=INF; } } rep(i,0,m){ cin>>a[i]>>b[i]>>c[i]; a[i]--,b[i]--; dis[a[i]][b[i]]=min(dis[a[i]][b[i]],c[i]); dist[b[i]][a[i]]=min(dis[b[i]][a[i]],c[i]); } rep(k,0,n){ rep(i,0,n){ rep(j,0,n){ dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]); } } } //ワーシャルフロイド法により, //全ての経路を最短化した. //この時、j==a[i]ならa[i]→b[i]が最短経路となっている; int ans=m; rep(i,0,m){ bool f=false; rep(j,0,n)if(dis[j][a[i]]+c[i]==dis[j][b[i]])f=true; if(f)ans--; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:26:17: error: 'dist' was not declared in this scope; did you mean 'dis'? 26 | dist[b[i]][a[i]]=min(dis[b[i]][a[i]],c[i]); | ^~~~ | dis
s315088733
p03837
C++
#include <bits/stdc++.h> using namespace std; vector<vector<int>> path(110,vector<int>(110,-1)); int shorter(int s,int e){ if(path[s][e] == -1) return 0; int MIN = path[s][e]; for(int i = 0;i < 110;i++){ if(path[s][i]==-1)break; else{ MIN = min(MIN,shorter(i,e)); } } if(MIN < path[s][e])return 1; else 0; } int main(){ int n,m; cin >> n >> m; int ans = 0; for(int i = 0;i < m;i++){ int a,b,c; cin >> a >> b >> c; path[a][b] = c; path[b][a] = c; } for(int i = 1;i <= n;i++){ path[i][i] = 0; } for(int i = 1;i <= n;i++){ for(int j = 1 < i;j++){ ans += shorter(i,j); } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:30:26: error: expected ';' before ')' token 30 | for(int j = 1 < i;j++){ | ^ | ; a.cc: In function 'int shorter(int, int)': a.cc:15:1: warning: control reaches end of non-void function [-Wreturn-type] 15 | } | ^
s140687997
p03837
C++
#include <stdio.h> using namespace std; int main(void) { const int inf = 100000000; int n, m; cin >> n >> m; int a[1000], b[1000], c[1000], dist[100][100]; for (int i = 0; i < m; ++i) { cin >> a[i] >> b[i] >> c[i]; a[i]--, b[i]--; } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i == j) { dist[i][j] = 0; } else { dist[i][j] = inf; } } } for (int i = 0; i < m; ++i) { dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]); dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]); } for (int k = 0; k < n; ++k) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } } int ans = m; for (int i = 0; i < m; ++i) { bool shortest = false; for (int j = 0; j < n; ++j) { if (dist[j][a[i]] + c[i] == dist[j][b[i]]) { shortest = true; } } if (shortest == true) { ans = ans - 1; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:8:5: error: 'cin' was not declared in this scope 8 | cin >> n >> m; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <stdio.h> +++ |+#include <iostream> 2 | using namespace std; a.cc:35:28: error: 'min' was not declared in this scope; did you mean 'main'? 35 | dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]); | ^~~ | main a.cc:45:30: error: 'min' was not declared in this scope; did you mean 'main'? 45 | dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); | ^~~ | main a.cc:68:5: error: 'cout' was not declared in this scope 68 | cout << ans << endl; | ^~~~ a.cc:68:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:68:20: error: 'endl' was not declared in this scope 68 | cout << ans << endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include <stdio.h> +++ |+#include <ostream> 2 | using namespace std;
s563801670
p03837
C++
int main(void) { const int inf = 100000000; int n, m; cin >> n >> m; int a[1000], b[1000], c[1000], dist[100][100]; for (int i = 0; i < m; ++i) { cin >> a[i] >> b[i] >> c[i]; a[i]--, b[i]--; } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i == j) { dist[i][j] = 0; } else { dist[i][j] = inf; } } } for (int i = 0; i < m; ++i) { dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]); dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]); } for (int k = 0; k < n; ++k) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } } int ans = m; for (int i = 0; i < m; ++i) { bool shortest = false; for (int j = 0; j < n; ++j) { if (dist[j][a[i]] + c[i] == dist[j][b[i]]) { shortest = true; } } if (shortest == true) { ans = ans - 1; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:6:5: error: 'cin' was not declared in this scope 6 | cin >> n >> m; | ^~~ a.cc:33:28: error: 'min' was not declared in this scope; did you mean 'main'? 33 | dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]); | ^~~ | main a.cc:43:30: error: 'min' was not declared in this scope; did you mean 'main'? 43 | dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); | ^~~ | main a.cc:66:5: error: 'cout' was not declared in this scope 66 | cout << ans << endl; | ^~~~ a.cc:66:20: error: 'endl' was not declared in this scope 66 | cout << ans << endl; | ^~~~
s326469756
p03837
C++
#include <iostream> #include <vector> #include <queue> #define forn(i, n) for (int i = 0; i < (int)n; ++i) #define for1(i, n) for (int i = 1; i <= (int)n; ++i) #define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) #define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i) #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define INF (1 << 30) using namespace std; typedef long long i64; typedef vector<int> vi; typedef vector<i64> vi64; typedef vector<vi> vvi; typedef vector<vi64> vvi64; typedef double ld; int d[100][100]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed; int N, M; cin >> N >> M; memset(d, INF, sizeof(d[0][0]) * 100 * 100); vi a(M), b(M), c(M); forn(i, M) { cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--; d[a[i]][b[i]] = c[i]; d[b[i]][a[i]] = c[i]; } forn(k, N) { forn(i, N) { forn(j, N) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } int ans = 0; forn(k, M) { if (d[a[k]][b[k]] != c[k]) ans++; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:37:5: error: 'memset' was not declared in this scope 37 | memset(d, INF, sizeof(d[0][0]) * 100 * 100); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <queue> +++ |+#include <cstring> 4 |
s958644848
p03837
C++
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> #include <vector> #include <iomanip> #define ALL(x) (x).begin(), (x).end() #define dll(x) scanf("%I64d",&x) #define xll(x) printf("%I64d\n",x) #define sz(a) int(a.size()) #define all(a) a.begin(), a.end() #define rep(i,x,n) for(int i=x;i<n;i++) #define repd(i,x,n) for(int i=x;i<=n;i++) #define pii pair<int,int> #define pll pair<long long ,long long> #define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) #define MS0(X) memset((X), 0, sizeof((X))) #define MSC0(X) memset((X), '\0', sizeof((X))) #define pb push_back #define mp make_pair #define fi first #define se second #define eps 1e-6 #define gg(x) getInt(&x) #define db(x) cout<<"== [ "<<x<<" ] =="<<endl; using namespace std; typedef long long ll; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;} inline void getInt(int* p); const int maxn=1000010; const int inf=100000000; /*** TEMPLATE CODE * * STARTS HERE ***/ int d[500][500]; int n,m; int a[500]; int b[500]; int c[500]; int main() { // freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin); // freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout); gbtb; cin>>n>>m; repd(i,1,m) { cin>>a[i]>>b[i]>>c[i]; } repd(i,1,n) { repd(j,1,n) { d[i][j] = d[j][i] = i==j?0:inf; } } repd(i,1,m) { dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]); dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]); } repd(k,1,m) { repd(i,1,n) { repd(j,1,n) { d[i][j]=d[j][i]=min(d[j][i],d[i][a[k]]+d[b[k]][j]+c[k]); } } } int ans=0; repd(k,1,m) { if(d[a[k]][b[k]]<c[k]) { ans++; } } cout<<ans<<endl; return 0; } inline void getInt(int* p) {char ch;do {ch = getchar();} while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0'); while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}} else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 + ch - '0';}}}
a.cc: In function 'int main()': a.cc:64:17: error: 'dist' was not declared in this scope 64 | dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]); | ^~~~
s198652517
p03837
C++
#include<bits/stdc++.h> #define x first #define y second #define ll long long #define pii pair<int, int> #define maxn 1005 #define INF 0x7FFFFFFF #define dbg(n) cout << n << endl #define mod 1000000007 using namespace std; inline void read(int &x){ int f = 1; x = 0; char s = getchar(); while(s > '9' || s < '0'){ if(s == '-') f = -1; s = getchar(); } while(s <= '9' && s >= '0'){ x = x * 10 + s - '0'; s = getchar(); } x = x * f; } struct E{ int f, t, c; E(int f, int t, int c) : f(f), t(t), c(c){ }; }; int G1[1005]; vector<int> GG1[1005]; int main(){ int n, m, f, t, c; read(n), read(m); for(int i = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) G1[i][j] = INF; for(int i = 0; i < m; ++i){ read(f); read(t); read(c); G1[f][t] = c; GG1[f].push_back(E(f, t, c)); } for(int i = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) for(int k = 0; k <= n; ++k) G1[i][j] = min(G1[i][j], G1[i][k] + G1[k][j]); int ans = 0; for(int i = 0; i <= n; ++i) for(int j = 0; j < GG[i].size(); ++j) if(GG1[i][j].c > G1[i][GG1[i][j].t]) ans++; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:39:30: error: invalid types 'int[int]' for array subscript 39 | G1[i][j] = INF; | ^ a.cc:42:22: error: invalid types 'int[int]' for array subscript 42 | G1[f][t] = c; | ^ a.cc:43:33: error: no matching function for call to 'std::vector<int>::push_back(E)' 43 | GG1[f].push_back(E(f, t, c)); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]' 1283 | push_back(const value_type& __x) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1283:35: note: no known conversion for argument 1 from 'E' to 'const std::vector<int>::value_type&' {aka 'const int&'} 1283 | push_back(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]' 1300 | push_back(value_type&& __x) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1300:30: note: no known conversion for argument 1 from 'E' to 'std::vector<int>::value_type&&' {aka 'int&&'} 1300 | push_back(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:48:38: error: invalid types 'int[int]' for array subscript 48 | G1[i][j] = min(G1[i][j], G1[i][k] + G1[k][j]); | ^ a.cc:48:53: error: invalid types 'int[int]' for array subscript 48 | G1[i][j] = min(G1[i][j], G1[i][k] + G1[k][j]); | ^ a.cc:48:63: error: invalid types 'int[int]' for array subscript 48 | G1[i][j] = min(G1[i][j], G1[i][k] + G1[k][j]); | ^ a.cc:48:74: error: invalid types 'int[int]' for array subscript 48 | G1[i][j] = min(G1[i][j], G1[i][k] + G1[k][j]); | ^ a.cc:51:36: error: 'GG' was not declared in this scope; did you mean 'GG1'? 51 | for(int j = 0; j < GG[i].size(); ++j) | ^~ | GG1 a.cc:52:38: error: request for member 'c' in 'GG1[i].std::vector<int>::operator[](((std::vector<int>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 52 | if(GG1[i][j].c > G1[i][GG1[i][j].t]) ans++; | ^ a.cc:52:58: error: request for member 't' in 'GG1[i].std::vector<int>::operator[](((std::vector<int>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 52 | if(GG1[i][j].c > G1[i][GG1[i][j].t]) ans++; | ^
s178466727
p03837
C++
#include<bits/stdc++.h> #define x first #define y second #define ll long long #define pii pair<int, int> #define maxn 1005 #define INF 0x7FFFFFFF #define dbg(n) cout << n << endl #define mod 1000000007 using namespace std; inline void read(int &x){ int f = 1; x = 0; char s = getchar(); while(s > '9' || s < '0'){ if(s == '-') f = -1; s = getchar(); } while(s <= '9' && s >= '0'){ x = x * 10 + s - '0'; s = getchar(); } x = x * f; } struct E{ int f, t, c; E(int f, int t, int c) : f(f), t(t), c(c){ }; }; int G[1005]; vector<int> GG[1005]; int main(){ int n, m, f, t, c; read(n), read(m); for(int i = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) G[i][j] = INF; for(int i = 0; i < m; ++i){ read(f); read(t); read(c); G[f][t] = c; GG[f].push_back(E(f, t, c)); } for(int i = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) for(int k = 0; k <= n; ++k) G[i][j] = min(G[i][j], G[i][k] + G[k][j]); int ans = 0; for(int i = 0; i <= n; ++i) for(int j = 0; j < GG[i].size(); ++j) if(GG[i][j].c > G[i][GG[i][j].t]) ans++; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:39:29: error: invalid types 'int[int]' for array subscript 39 | G[i][j] = INF; | ^ a.cc:42:21: error: invalid types 'int[int]' for array subscript 42 | G[f][t] = c; | ^ a.cc:43:32: error: no matching function for call to 'std::vector<int>::push_back(E)' 43 | GG[f].push_back(E(f, t, c)); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]' 1283 | push_back(const value_type& __x) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1283:35: note: no known conversion for argument 1 from 'E' to 'const std::vector<int>::value_type&' {aka 'const int&'} 1283 | push_back(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]' 1300 | push_back(value_type&& __x) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1300:30: note: no known conversion for argument 1 from 'E' to 'std::vector<int>::value_type&&' {aka 'int&&'} 1300 | push_back(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:48:37: error: invalid types 'int[int]' for array subscript 48 | G[i][j] = min(G[i][j], G[i][k] + G[k][j]); | ^ a.cc:48:51: error: invalid types 'int[int]' for array subscript 48 | G[i][j] = min(G[i][j], G[i][k] + G[k][j]); | ^ a.cc:48:60: error: invalid types 'int[int]' for array subscript 48 | G[i][j] = min(G[i][j], G[i][k] + G[k][j]); | ^ a.cc:48:70: error: invalid types 'int[int]' for array subscript 48 | G[i][j] = min(G[i][j], G[i][k] + G[k][j]); | ^ a.cc:52:37: error: request for member 'c' in 'GG[i].std::vector<int>::operator[](((std::vector<int>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 52 | if(GG[i][j].c > G[i][GG[i][j].t]) ans++; | ^ a.cc:52:55: error: request for member 't' in 'GG[i].std::vector<int>::operator[](((std::vector<int>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 52 | if(GG[i][j].c > G[i][GG[i][j].t]) ans++; | ^
s030298756
p03837
C++
#include "bits/stdc++.h" using namespace std; #define PB push_back #define MP make_pair #define ALL(a) (a).begin(),(a).end() #define REP(i,n) for(int i=0;i<(n);i++) int d[100][100]; int main(){ int n,m; int a[1000],b[1000],c[1000]; cin>>n>>m; REP(i,n)REP(j,n)d[i][j]=1e9; REP(i,n)d[i][j]=0; REP(i,m){ cin>>a[i]>>b[i]>>c[i]; a[i]--;b[i]--: d[a[i]][b[i]]=d[b[i]][a[i]]=c[i]; } REP(k,n) REP(i,n) REP(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]); int cnt=0; REP(i,m)if(d[a[i]][b[i]]<c[i])cnt++; cout<<cnt<<endl; }
a.cc: In function 'int main()': a.cc:13:18: error: 'j' was not declared in this scope 13 | REP(i,n)d[i][j]=0; | ^ a.cc:16:22: error: expected ';' before ':' token 16 | a[i]--;b[i]--: | ^ | ;
s650568317
p03837
C++
#include <iostream> #include <vector> #include <utility> using namespace std; int d[110][110] = {}; int n, m, inf = 1e9 + 7, a[1010], b[1010], c[1010], ans; bool used[1010]; void warshall_floyd(int n) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { d[j][k] = min(d[j][k], d[j][i] + d[i][k]); } } } } int main() { cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { d[i][j] = (i == j ? 0 : inf); } } for (int i = 0; i < m; i++) { scanf("%d%d%d", % a[i], &b[i], &c[i]); a[i]--, b[i]--, d[a[i]][b[i]] = c[i], d[b[i]][a[i]] = c[i]; } warshall_floyd(n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) continue; for (int k = 0; k < m; k++) { used[k] = used[k] || d[i][a[k]] + c[k] + d[b[k]][j] == d[i][j] || d[i][b[k]] + c[k] + d[a[k]][j] == d[i][j]; } } } for (int i = 0; i < m; i++) ans += !used[i]; printf("%d\n", ans); }
a.cc: In function 'int main()': a.cc:36:25: error: expected primary-expression before '%' token 36 | scanf("%d%d%d", % a[i], &b[i], &c[i]); | ^
s841373734
p03837
C++
#include<iostream> #include<algorithm> #include<cmath> #include<cstring> #include<cstdlib> #include<ctime> #include<cstdio> #include<string> //#include<string> //#include<sstream> using namespace std; const int MAX_V=10000+5; const int INF=1<<30; int pre[MAX_V]; int cost[MAX_V][MAX_V];//cost[u][v]表示边e=(u,v)的权值(不存在这条边时设为INF) bool visited[MAX_V][MAX_V]; int d[MAX_V];//顶点s出发的最短距离 bool used[MAX_V];//已经使用过的图 int V,E;//顶点数,边数 //求从起点s出发到各个顶点的最短距离 void dijkstra(int s) { fill(d+1,d+V+1,INF); fill(used+1,used+V+1,false); fill(pre+1,pre+V+1,-1); d[s]=0; while(true) { int v=-1; //从尚未使用过的顶点中选择一个距离最小的顶点 for(int u=1; u<=V; u++) { if(!used[u]&&(v==-1||d[u]<d[v])) v=u; } if(v==-1) break; used[v]=true; for(int u=1; u<=V; u++) { if(d[u]>d[v]+cost[v][u]) { d[u]=d[v]+cost[v][u]; pre[u]=v; } } } } vector<int> get_path(int t) { vector<int>path; for(; t!=-1; t=pre[t]) path.push_back(t); reverse(path.begin(),path.end()); return path; } int main() { scanf("%d%d",&V,&E); int a,b,c; for(int i=1;i<=V;i++) { for(int j=1;j<=V;j++) cost[i][j]=INF; } for(int i=0;i<E;i++) { scanf("%d%d%d",&a,&b,&c); cost[a][b]=cost[b][a]=c; } memset(visited,false,sizeof(visited)); int ans=E; for(int i=1;i<=V;i++) { dijkstra(i); for(int j=1;j<=V;j++) { if(i==j) continue; vector<int>v=get_path(j); for(int i=0;i<v.size()-1;i++) { int a=v[i]; int b=v[i+1]; if(!visited[v[i]][v[i+1]]&&!visited[v[i+1]][v[i]]) { visited[v[i]][v[i+1]]=visited[v[i+1]][v[i]]=true; ans--; } } } } printf("%d\n",ans); return 0; }
a.cc:49:1: error: 'vector' does not name a type 49 | vector<int> get_path(int t) | ^~~~~~ a.cc: In function 'int main()': a.cc:80:13: error: 'vector' was not declared in this scope 80 | vector<int>v=get_path(j); | ^~~~~~ a.cc:8:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 7 | #include<cstdio> +++ |+#include <vector> 8 | #include<string> a.cc:80:20: error: expected primary-expression before 'int' 80 | vector<int>v=get_path(j); | ^~~ a.cc:81:27: error: 'v' was not declared in this scope 81 | for(int i=0;i<v.size()-1;i++) | ^
s988021742
p03837
C
//答え見たよ!!! #include<stdio.h> #define INFINITY 9999999 struct Neighborhood{ int dist;//結ばれた2つのノードの距離 int no;//辺の番号 }; int main(){ int i, j; //入力 int N, M; scanf("%d %d", &N, &M); int a[M+1], b[M+1], c[M+1];//a[0], b[0], c[0]は使わない for(i=1; i<=M; i++) scanf("%d %d %d", &a[i], &b[i], &c[i]); //入力ここまで int dist[N+1][N+1];//最短距離 //初期値の設定 for(j=1; j<=N; j++){ for(i=1; i<=N; i++){ if(i=j){ dist[i][j] = 0; }else{ dist[i][j] = INFINITY; } } } struct Neighborhood nbh[N+1][N+1]; //頂点が直接結ばれているならばを距離と辺の番号を代入 for(i=1; i<=M; i++){ nbh[a[i]][b[i]].dist = c[i]; nbh[b[i]][a[i]].dist = c[i]; nbh[a[i]][b[i]].no = i; nbh[b[i]][a[i]].no = i; } //各頂点を始点とした最短経路をDijkstra法で求め、 //それぞれの辺が最短経路に含まれるかをみる int s;//スタートとして使用 int t;//暫定的な起点として使用 int from[N+1];//点sを起点とする最短距離において、各頂点に対しどの辺から来たかを代入する int fix[N+1];//各頂点について値が確定したら1、そうでないなら0 int temp_min;//最小値を記録 int min_edge;//最小値をもつ頂点 int cnt;//N-1回最短距離を確定させるためのカウンター int use[M+1];//各辺について最短経路として使われたら1 for(s=1; s<N; s++){ for(i=1; i<=N; i++) fix[i] = 0; fix[s] = 1; t = s; for(cnt=1; cnt<N; cnt++){ //このときdist(s,t)は確定していることに注意 //頂点tに隣り合っていてなおかつ確定していない場所をすべて探索する for(i=1; i<=N; i++){ if(nbh[t][i] && !fix[i]){ dist[s][i] = dist[s][t] + nbh[t][i]; from[i] = nbh[t][i].no; } } //このとき未確定の頂点のうち距離が最小のものが確定する temp_min = 9999; for(i=1; i<=N; i++){ if(!fix[i] && dist[s][i] < temp_min){ temp_min = dist[s][i]; min_edge = i; } } fix[min_edge] = 1; t = min_edge; } //頂点s始点のすべての最短距離が出たので使われた経路を記録する for(i=1; i<=N; i++) use[from[i]] = 1; } //すべての頂点を始点とした最短距離を探索し終わったので int ans = 0;//最短経路に含まれない辺の本数を数え上げる for(i=1; i<=M; i++){ if(!use[i]) ans++; } printf("%d\n", ans); return 0; }
main.c: In function 'main': main.c:59:12: error: used struct type value where scalar is required 59 | if(nbh[t][i] && !fix[i]){ | ^~~ main.c:60:35: error: invalid operands to binary + (have 'int' and 'struct Neighborhood') 60 | dist[s][i] = dist[s][t] + nbh[t][i]; | ~~~~~~~~~~ ^ ~~~~~~~~~ | | | | int struct Neighborhood
s512717839
p03837
C
//答え見たよ!!! #include<stdio.h> #define INFINITY 9999999 struct Neighborhood{ int dist;//結ばれた2つのノードの距離 int no;//辺の番号 }; int main(){ int i, j; //入力 int N, M; scanf("%d %d", &N, &M); int a[M+1], b[M+1], c[M+1];//a[0], b[0], c[0]は使わない for(i=1; i<=M; i++) scanf("%d %d %d", &a[i], &b[i], &c[i]); //入力ここまで int dist[N+1][N+1];//最短距離 //初期値の設定 for(j=1; j<=N; j++){ for(i=1; i<=N; i++){ if(i=j){ dist[i][j] = 0; }else{ dist[i][j] = INFINITY; } } } Neighborhood nbh[N+1][N+1]; //頂点が直接結ばれているならばを距離と辺の番号を代入 for(i=1; i<=M; i++){ nbh[a[i]][b[i]].dist = c[i]; nbh[b[i]][a[i]].dist = c[i]; nbh[a[i]][b[i]].no = i; nbh[b[i]][a[i]].no = i; } //各頂点を始点とした最短経路をDijkstra法で求め、 //それぞれの辺が最短経路に含まれるかをみる int s;//スタートとして使用 int t;//暫定的な起点として使用 int from[N+1];//点sを起点とする最短距離において、各頂点に対しどの辺から来たかを代入する int fix[N+1];//各頂点について値が確定したら1、そうでないなら0 int temp_min;//最小値を記録 int min_edge;//最小値をもつ頂点 int cnt;//N-1回最短距離を確定させるためのカウンター int use[M+1];//各辺について最短経路として使われたら1 for(s=1; s<N; s++){ for(i=1; i<=N; i++) fix[i] = 0; fix[s] = 1; t = s; for(cnt=1; cnt<N; cnt++){ //このときdist(s,t)は確定していることに注意 //頂点tに隣り合っていてなおかつ確定していない場所をすべて探索する for(i=1; i<=N; i++){ if(nbh[t][i] && !fix[i]){ dist[s][i] = dist[s][t] + nbh[t][i]; from[i] = nbh[t][i].no; } } //このとき未確定の頂点のうち距離が最小のものが確定する temp_min = 9999; for(i=1; i<=N; i++){ if(!fix[i] && dist[s][i] < temp_min){ temp_min = dist[s][i]; min_edge = i; } } fix[min_edge] = 1; t = min_edge; } //頂点s始点のすべての最短距離が出たので使われた経路を記録する for(i=1; i<=N; i++) use[from[i]] = 1; } //すべての頂点を始点とした最短距離を探索し終わったので int ans = 0;//最短経路に含まれない辺の本数を数え上げる for(i=1; i<=M; i++){ if(!use[i]) ans++; } printf("%d\n", ans); return 0; }
main.c: In function 'main': main.c:31:3: error: unknown type name 'Neighborhood'; use 'struct' keyword to refer to the type 31 | Neighborhood nbh[N+1][N+1]; | ^~~~~~~~~~~~ | struct main.c:34:20: error: request for member 'dist' in something not a structure or union 34 | nbh[a[i]][b[i]].dist = c[i]; | ^ main.c:35:20: error: request for member 'dist' in something not a structure or union 35 | nbh[b[i]][a[i]].dist = c[i]; | ^ main.c:36:20: error: request for member 'no' in something not a structure or union 36 | nbh[a[i]][b[i]].no = i; | ^ main.c:37:20: error: request for member 'no' in something not a structure or union 37 | nbh[b[i]][a[i]].no = i; | ^ main.c:61:30: error: request for member 'no' in something not a structure or union 61 | from[i] = nbh[t][i].no; | ^
s943058276
p03837
C
//答え見たよ!!! #include<stdio.h> #define INFINITY 9999999 struct Neighborhood{ int dist;//結ばれた2つのノードの距離 int no;//辺の番号 } int main(){ int i, j; //入力 int N, M; scanf("%d %d", &N, &M); int a[M+1], b[M+1], c[M+1];//a[0], b[0], c[0]は使わない for(i=1; i<=M; i++) scanf("%d %d %d", &a[i], &b[i], &c[i]); //入力ここまで int dist[N+1][N+1];//最短距離 //初期値の設定 for(j=1; j<=N; j++){ for(i=1; i<=N; i++){ if(i=j){ dist[i][j] = 0; }else{ dist[i][j] = INFINITY; } } } Neighborhood nbh[N+1][N+1]; //頂点が直接結ばれているならばを距離と辺の番号を代入 for(i=1; i<=M; i++){ nbh[a[i]][b[i]].dist = c[i]; nbh[b[i]][a[i]].dist = c[i]; nbh[a[i]][b[i]].no = i; nbh[b[i]][a[i]].no = i; } //各頂点を始点とした最短経路をDijkstra法で求め、 //それぞれの辺が最短経路に含まれるかをみる int s;//スタートとして使用 int t;//暫定的な起点として使用 int from[N+1];//点sを起点とする最短距離において、各頂点に対しどの辺から来たかを代入する int fix[N+1];//各頂点について値が確定したら1、そうでないなら0 int temp_min;//最小値を記録 int min_edge;//最小値をもつ頂点 int cnt;//N-1回最短距離を確定させるためのカウンター int use[M+1];//各辺について最短経路として使われたら1 for(s=1; s<N; s++){ for(i=1; i<=N; i++) fix[i] = 0; fix[s] = 1; t = s; for(cnt=1; cnt<N; cnt++){ //このときdist(s,t)は確定していることに注意 //頂点tに隣り合っていてなおかつ確定していない場所をすべて探索する for(i=1; i<=N; i++){ if(nbh[t][i] && !fix[i]){ dist[s][i] = dist[s][t] + nbh[t][i]; from[i] = nbh[t][i].no; } } //このとき未確定の頂点のうち距離が最小のものが確定する temp_min = 9999; for(i=1; i<=N; i++){ if(!fix[i] && dist[s][i] < temp_min){ temp_min = dist[s][i]; min_edge = i; } } fix[min_edge] = 1; t = min_edge; } //頂点s始点のすべての最短距離が出たので使われた経路を記録する for(i=1; i<=N; i++) use[from[i]] = 1; } //すべての頂点を始点とした最短距離を探索し終わったので int ans = 0;//最短経路に含まれない辺の本数を数え上げる for(i=1; i<=M; i++){ if(!use[i]) ans++; } printf("%d\n", ans); return 0; }
main.c:10:1: error: expected ';', identifier or '(' before 'int' 10 | int main(){ | ^~~ main.c: In function 'main': main.c:31:3: error: unknown type name 'Neighborhood'; use 'struct' keyword to refer to the type 31 | Neighborhood nbh[N+1][N+1]; | ^~~~~~~~~~~~ | struct main.c:34:20: error: request for member 'dist' in something not a structure or union 34 | nbh[a[i]][b[i]].dist = c[i]; | ^ main.c:35:20: error: request for member 'dist' in something not a structure or union 35 | nbh[b[i]][a[i]].dist = c[i]; | ^ main.c:36:20: error: request for member 'no' in something not a structure or union 36 | nbh[a[i]][b[i]].no = i; | ^ main.c:37:20: error: request for member 'no' in something not a structure or union 37 | nbh[b[i]][a[i]].no = i; | ^ main.c:61:30: error: request for member 'no' in something not a structure or union 61 | from[i] = nbh[t][i].no; | ^
s815914310
p03837
C
//答え見たよ!!! #include<stdio.h> #define INFINITY 9999999 int main(){ int i, j; //入力 int N, M; scanf("%d %d", &N, &M); int a[M+1], b[M+1], c[M+1];//a[0], b[0], c[0]は使わない for(i=1; i<=M; i++) scanf("%d %d %d", &a[i], &b[i], &c[i]); //入力ここまで int ans = M;//最短経路に含まれない辺の本数 int dist[N+1][N+1];//最短距離 int nbh[N+1][N+1];//隣接しているか? //初期値の設定 for(j=1; j<=N; j++){ for(i=1; i<=N; i++){ if(i=j){ dist[i][j] = 0; }else{ dist[i][j] = INFINITY; } } } //隣接している場所へ距離を代入 for(i=1; i<=M; i++){ nbh[a[i]][b[i]] = c[i]; nbh[b[i]][a[i]] = c[i]; } int s;//スタートとして使用 int t;//暫定的な起点として使用 //各頂点を始点とした最短経路をDijkstra法で求め、 //それぞれの辺が最短経路に含まれるかをみる for(s=1; s<N; s++){ t = s; for(i=1; i<=M; i++){ if(nbh[t][i]) dist[s][i] = dist[s][t] + nbh[t][i];
main.c: In function 'main': main.c:41:9: error: expected declaration or statement at end of input 41 | dist[s][i] = dist[s][t] + nbh[t][i]; | ^~~~ main.c:41:9: error: expected declaration or statement at end of input main.c:41:9: error: expected declaration or statement at end of input
s664369838
p03837
C++
//Warshall-Floyd #include<iostream> #include<vector> #include<algorithm> using namespace std; int main(void){ int N, M; cin >> N >> M; vector<int> a(M), b(M); vector<long long> c(M); vector<vector<long long>> d(N, vector<long long>(N, LLONG_MAX / 2)); vector<vector<vector<int>>> p(N, vector<vector<int>>(N, vector<int>(0))); for(int i = 0; i < M; i++){ cin >> a[i]; cin >> b[i]; cin >> c[i]; a[i]--; b[i]--; d[a[i]][b[i]] = c[i]; d[b[i]][a[i]] = c[i]; p[a[i]][b[i]].push_back(i); p[b[i]][a[i]].push_back(i); } for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ for(int k = 0; k < N; k++){ if(d[j][k] > d[j][i] + d[i][k]){ d[j][k] = d[k][j] = d[j][i] + d[i][k]; p[j][k].clear(); p[j][k].resize(p[j][i].size() + p[i][k].size()); p[j][k] = p[j][i]; for(auto itr = p[i][k].begin(); itr != p[i][k].end(); itr++) p[j][k].push_back(*itr); p[k][j].clear(); p[k][j].resize(p[j][k].size()); for(auto itr = p[j][k].rbegin(); itr != p[j][k].rend(); itr++) p[k][j].push_back(*itr); } } } } vector<bool> check(M, false); for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ // cout << i << " " << j << " " << d[i][j] << " "; for(auto itr = p[i][j].begin(); itr != p[i][j].end(); itr++){ // cout << " " << *itr; check[*itr] = true; } // cout << endl; } } int ans = 0; for(auto itr = check.begin(); itr != check.end(); itr++) if(!*itr) ans++; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:57: error: 'LLONG_MAX' was not declared in this scope 14 | vector<vector<long long>> d(N, vector<long long>(N, LLONG_MAX / 2)); | ^~~~~~~~~ a.cc:6:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 5 | #include<algorithm> +++ |+#include <climits> 6 |
s444625035
p03837
C++
#include <bits/stdc++.h> const int INF = 1e9; const int MOD = 1e9+7; const long long LINF = 1e18; #define dump(x) cout << 'x' << ' = ' << (x) << ` `; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) for(int i=0;i<(n);++i) #define REPR(i,n) for(int i=n;i>=0;i--) #define FOREACH(x,a) for(auto& (x) : (a) ) typedef long long ll; using namespace std; typedef struct DP { int dist; int from; bool sure; } DP; //自作構造体にしたいけど比較演算子の定義がわからないので保留 typedef pair<int, int> P; int main(int argc, char const *argv[]) { int n, m; cin >> n >> m; int G[n][n]; bool E[n][n]; REP(i,n) REP(j,n) G[i][j] = INF; REP(i,n) REP(j,n) E[i][j] = false; REP(i,m) { int a, b, c; cin >> a >> b >> c; G[a-1][b-1] = G[b-1][a-1] = c; } DP dp(n); for (int I = 0; I < n; ++I) { REP(i,n) { dp[i].dist = INF; dp[i].from = INF; dp[i].sure = false; } priority_queue<P, vector<P>, greater<P>> pq; P p = P(0, I); pq.push(p); dp[I].dist = 0; dp[I].from = I; while(!pq.empty()){ P now = pq.top(); int v = now.second; if(dp[v].sure)continue; dp[v].sure = true; pq.pop(); REP(i,n) { if(G[v][i] != INF && dp[i].sure == false) { //dp[i].dist = min(dp[v].dist+G[v][i], dp[i].dist);←本当はこうしたいが、fromの更新をするためにはどうせifがいる if (dp[v].dist+G[v][i] <= dp[i].dist) { dp[i].dist = dp[v].dist+G[v][i]; dp[i].from = v; P temp = P(dp[i].dist, i); pq.push(temp); } } } } /*cout << "------------------------dist------------------------" << std::endl; REP(i,n) cout << i+1 << " = " << dp[i].dist << std::endl; cout << "------------------------from------------------------" << std::endl; REP(i,n) if (i != dp[i].from) cout << dp[i].from+1 << " -> " << i+1 << std::endl;*/ REP(i,n) if (i != dp[i].from) E[dp[i].from][i] = E[i][dp[i].from] = true; } int c = 0; //cout << "------------------------egde------------------------" << std::endl; REP(i,n) { REP(j,n) { //cout << E[i][j] << " "; if(E[i][j]) c++; } //cout << "" << std::endl; } int ans = m-(c/2); cout << ans << std::endl; return 0; /*cout << "------------------------dist------------------------" << std::endl; REP(i,n) cout << i << " = " << dp[i].dist << std::endl; cout << "------------------------from------------------------" << std::endl; REP(i,n) cout << i << " = " << dp[i].from << std::endl; */ }
a.cc: In function 'int main(int, const char**)': a.cc:36:12: error: no matching function for call to 'DP::DP(int&)' 36 | DP dp(n); | ^ a.cc:13:16: note: candidate: 'DP::DP()' 13 | typedef struct DP { | ^~ a.cc:13:16: note: candidate expects 0 arguments, 1 provided a.cc:13:16: note: candidate: 'constexpr DP::DP(const DP&)' a.cc:13:16: note: no known conversion for argument 1 from 'int' to 'const DP&' a.cc:13:16: note: candidate: 'constexpr DP::DP(DP&&)' a.cc:13:16: note: no known conversion for argument 1 from 'int' to 'DP&&' a.cc:41:15: error: no match for 'operator[]' (operand types are 'DP' and 'int') 41 | dp[i].dist = INF; | ^ a.cc:42:15: error: no match for 'operator[]' (operand types are 'DP' and 'int') 42 | dp[i].from = INF; | ^ a.cc:43:15: error: no match for 'operator[]' (operand types are 'DP' and 'int') 43 | dp[i].sure = false; | ^ a.cc:48:11: error: no match for 'operator[]' (operand types are 'DP' and 'int') 48 | dp[I].dist = 0; | ^ a.cc:49:11: error: no match for 'operator[]' (operand types are 'DP' and 'int') 49 | dp[I].from = I; | ^ a.cc:54:16: error: no match for 'operator[]' (operand types are 'DP' and 'int') 54 | if(dp[v].sure)continue; | ^ a.cc:55:15: error: no match for 'operator[]' (operand types are 'DP' and 'int') 55 | dp[v].sure = true; | ^ a.cc:58:40: error: no match for 'operator[]' (operand types are 'DP' and 'int') 58 | if(G[v][i] != INF && dp[i].sure == false) { | ^ a.cc:60:27: error: no match for 'operator[]' (operand types are 'DP' and 'int') 60 | if (dp[v].dist+G[v][i] <= dp[i].dist) { | ^ a.cc:60:49: error: no match for 'operator[]' (operand types are 'DP' and 'int') 60 | if (dp[v].dist+G[v][i] <= dp[i].dist) { | ^ a.cc:61:27: error: no match for 'operator[]' (operand types are 'DP' and 'int') 61 | dp[i].dist = dp[v].dist+G[v][i]; | ^ a.cc:61:40: error: no match for 'operator[]' (operand types are 'DP' and 'int') 61 | dp[i].dist = dp[v].dist+G[v][i]; | ^ a.cc:62:27: error: no match for 'operator[]' (operand types are 'DP' and 'int') 62 | dp[i].from = v; | ^ a.cc:63:35: error: no match for 'operator[]' (operand types are 'DP' and 'int') 63 | P temp = P(dp[i].dist, i); | ^ a.cc:75:29: error: no match for 'operator[]' (operand types are 'DP' and 'int') 75 | REP(i,n) if (i != dp[i].from) E[dp[i].from][i] = E[i][dp[i].from] = true; | ^ a.cc:75:43: error: no match for 'operator[]' (operand types are 'DP' and 'int') 75 | REP(i,n) if (i != dp[i].from) E[dp[i].from][i] = E[i][dp[i].from] = true; | ^ a.cc:75:65: error: no match for 'operator[]' (operand types are 'DP' and 'int') 75 | REP(i,n) if (i != dp[i].from) E[dp[i].from][i] = E[i][dp[i].from] = true; | ^
s790957233
p03837
C++
#include <iostream> #include <limits> #include <map> #include <vector> using namespace std; template <typename N = std::size_t, typename E = std::size_t> class DenseGraph { public: using NodeType = N; using EdgeType = E; using NeighborListType = std::vector<std::size_t>; DenseGraph(const std::size_t size, bool undirected = true) noexcept : neighbor_list_(size) , undirected_(undirected) , nodes_(size) { } void connect(const std::size_t from, const std::size_t to, const EdgeType edge) noexcept { const std::size_t new_size = std::max(from, to) + 1; if (neighbor_list_.size() < new_size) { neighbor_list_.resize(new_size); nodes_.resize(new_size); } if (undirected_) { neighbor_list_[from].push_back(to); edges_[std::make_pair(std::min(from, to), std::max(from, to))] = edge; } else { neighbor_list_[from].push_back(to); neighbor_list_[to].push_back(from); edges_[std::make_pair(from, to)] = edge; } } void disconnect(const std::size_t from, const std::size_t to) noexcept { if (undirected_) { neighbor_list_[from].erase(to); edges_.erase(std::make_pair(std::min(from, to), std::max(from, to))); } else { neighbor_list_[from].erase(to); neighbor_list_[to].erase(from); edges_.erase(std::make_pair(from, to)); } } const NodeType& node(const std::size_t index) const noexcept { return nodes_.at(index); } const EdgeType& edge(const std::size_t from, const std::size_t to) const noexcept { if (undirected_) { auto key = std::make_pair(std::min(from, to), std::max(from, to)); return edges_.at(key); } else { auto key = std::make_pair(from, to); return edges_.at(key); } } const NeighborListType& neighbor(const std::size_t index) const noexcept { return neighbor_list_[index]; } std::size_t size() const noexcept { return neighbor_list_.size(); } private: using EdgeMap = std::map<std::pair<std::size_t, std::size_t>, EdgeType>; std::vector<NeighborListType> neighbor_list_; EdgeMap edges_; std::vector<NodeType> nodes_; bool undirected_; }; template <typename GraphType> std::vector<std::vector<int>> warshall_floyd(const GraphType& graph) { const std::size_t n = graph.size(); std::vector<std::vector<int>> distance(n, std::vector<int>(n, std::numeric_limits<int>::max() / 3)); for (int i = 0; i < n; i++) { distance[i][i] = 0; for (auto j : graph.neighbor(i)) { distance[i][j] = distance[j][i] = graph.edge(i, j); } } for (std::size_t k = 0; k < n; k++) { for (std::size_t i = 0; i < n; i++) { for (std::size_t j = 0; j < n; j++) { distance[i][j] = std::min(distance[i][j], distance[i][k] + distance[k][j]); } } } return distance; } int main() { int n, m; cin >> n >> m; DenseGraph<int, int> graph(n, true); for (int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; graph.connect(a - 1, b - 1, c); } auto distance = warshall_floyd(graph); int count = 0; for (int from = 0; from < n; from++) { for (int to : graph.neighbor(from)) { if (graph.edge(from, to) > distance[from][to]) { count++; } } } cout << count << endl; }
a.cc: In member function 'void DenseGraph<N, E>::disconnect(std::size_t, std::size_t)': a.cc:44:39: error: no matching function for call to 'std::vector<long unsigned int>::erase(const std::size_t&)' 44 | neighbor_list_[from].erase(to); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ In file included from /usr/include/c++/14/vector:66, from a.cc:4: /usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; iterator = std::vector<long unsigned int>::iterator; const_iterator = std::vector<long unsigned int>::const_iterator]' 1536 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/14/bits/stl_vector.h:1536:28: note: no known conversion for argument 1 from 'const std::size_t' {aka 'const long unsigned int'} to 'std::vector<long unsigned int>::const_iterator' 1536 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; iterator = std::vector<long unsigned int>::iterator; const_iterator = std::vector<long unsigned int>::const_iterator]' 1564 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate expects 2 arguments, 1 provided a.cc:47:39: error: no matching function for call to 'std::vector<long unsigned int>::erase(const std::size_t&)' 47 | neighbor_list_[from].erase(to); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ /usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; iterator = std::vector<long unsigned int>::iterator; const_iterator = std::vector<long unsigned int>::const_iterator]' 1536 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/14/bits/stl_vector.h:1536:28: note: no known conversion for argument 1 from 'const std::size_t' {aka 'const long unsigned int'} to 'std::vector<long unsigned int>::const_iterator' 1536 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; iterator = std::vector<long unsigned int>::iterator; const_iterator = std::vector<long unsigned int>::const_iterator]' 1564 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate expects 2 arguments, 1 provided a.cc:48:37: error: no matching function for call to 'std::vector<long unsigned int>::erase(const std::size_t&)' 48 | neighbor_list_[to].erase(from); | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; iterator = std::vector<long unsigned int>::iterator; const_iterator = std::vector<long unsigned int>::const_iterator]' 1536 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/14/bits/stl_vector.h:1536:28: note: no known conversion for argument 1 from 'const std::size_t' {aka 'const long unsigned int'} to 'std::vector<long unsigned int>::const_iterator' 1536 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; iterator = std::vector<long unsigned int>::iterator; const_iterator = std::vector<long unsigned int>::const_iterator]' 1564 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate expects 2 arguments, 1 provided
s258611047
p03837
C++
#include <stdio.h> #include <algorithm> #include < int main() { int n, m, distance[100][100]{}, edge[100][100]{}; std::fill(distance[0], distance[0] + 10000, 1000000000); scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { int a, b, c; scanf("%d%d%d", &a, &b, &c); a--; b--; distance[a][b] = distance[b][a] = edge[a][b] = edge[b][a] = c; } for (int i = 0; i < n; i++) distance[i][i] = 0; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) for (int k = 0; k < n; k++) { distance[j][i] = distance[i][j] = std::min(distance[i][j], distance[i][k] + distance[k][j]); } int count{}; for(int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) if (distance[i][j] < edge[i][j]) count++; printf("%d\n", count); return 0; }
a.cc:3:11: error: missing terminating > character 3 | #include < | ^ a.cc:3:10: error: empty filename in #include 3 | #include < | ^
s100484632
p03837
C++
x
a.cc:1:1: error: 'x' does not name a type 1 | x | ^
s930632107
p03837
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n,m;cin>>n>>m; int d[n+1][n+1]; for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)d[i][j]=-1; int s[n+1][n+1]; int a[m],b[m],c[m]; for(int i=0;i<m;i++){ cin>>a[i]>>b[i]>>c[i]; d[a[i]][b[i]]=c[i]; d[b[i]][a[i]]=c[i]; } for(int i=1;i<=n;i++){ s[i][i]=0; bool used[n+1]; for(int j=0;j<=n;j++)used[j]=false; for(;;){ int v=-1; for(int j=1;j<=n;j++){ if(used[i]==false||s[i][j]<s[i][v])v=j; } if(v==-1)break; used[v]=true; for(int j=1;j<=n;j++){ if(d[v][j]>=0){ s[i][j]=min(s[i][j],s[i][v]+d[v][j]); } } } } int ans=0; for(int i=0;i<m;i++){ int f=a[i]; int se=b[i]; for(int j=1;j<=n;j++){ if(s[f][j]+s[j][se]<c[i]){ ans++; break; } } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:43:4: error: expected '}' at end of input 43 | } | ^ a.cc:3:11: note: to match this '{' 3 | int main(){ | ^
s700880639
p03837
C++
#include<iostream> #include<algorithm> #include<math.h> #include<queue> #include<string> #include<vector> #include<tuple> #include<stack> #include<iomanip> #include<map> using namespace std; //def lib #define rep(i,n) for(int i=0;i<((int)n);i++) #define drep(i,n) for(int i=((int)n)-1;i>-1;i--) #define Rep(i,n0,n) for(int i=n0;i<((int)n);i++) #define dRep(i,n0,n) for(int i=((int)n)-1;i>n0-1;i--) #define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++) #define W(x) cout<<x<<endl; #define print(x) cout<<x<<endl; #define Debug(x) cout<<"#DEBUG "<<x<<endl; #define INF (1<<29) #define INF2 (long long)8*(long long)INF*(long long)INF #define mod 1000000007 //def end typedef long long ll; // lib int min(int x,int y){if(y<x)return y;else return x;} int max(int x,int y){if(y>x)return y;else return x;} int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;} int mfact(int x){int i=1;rep(j,x){i*=(j+1);} return i%mod;} int modulo(int x){return x%mod;} long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;} long long mfact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i%mod;} long long modulo(long long x){return x%mod;} int gcd(int x, int y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);} ll gcd(ll x, ll y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);} void say(bool x){if(x){cout<<"Yes"<<endl;}else {cout<<"No"<<endl;}return;} //lib end int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1}; int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1}; int main(void){ const int inf = 100000000; int n,m; cin>>n>>m; int a[1000],b[1000],c[1000],dist[100][100]; for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--; } for(inti=0;i< for(int j = 0; m; ++i){ b[i] >> c[i]; n; ++i){ j<n;++j){ } } if(i==j) dist[i][j]=0; else dist[i][j]=inf; for(inti=0;i<m;++i){ dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]); dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]); } for(intk=0;k<n;++k){ for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j){ dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]); } } } int ans=m; for(inti=0;i<m;++i){ bool shortest=false; for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true; if(shortest==true){ ans=ans-1; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:45:5: error: 'inti' was not declared in this scope; did you mean 'int'? 45 | for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--; | ^~~~ | int a.cc:45:12: error: 'i' was not declared in this scope 45 | for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--; | ^ a.cc:46:1: error: expected primary-expression before '}' token 46 | } | ^ a.cc:45:44: error: expected ')' before '}' token 45 | for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--; | ~ ^ | ) 46 | } | ~ a.cc:46:1: error: expected primary-expression before '}' token 46 | } | ^ a.cc: At global scope: a.cc:47:1: error: expected unqualified-id before 'for' 47 | for(inti=0;i< for(int j = 0; | ^~~ a.cc:47:12: error: 'i' does not name a type 47 | for(inti=0;i< for(int j = 0; | ^ a.cc:48:1: error: 'm' does not name a type; did you mean 'tm'? 48 | m; ++i){ | ^ | tm a.cc:48:4: error: expected unqualified-id before '++' token 48 | m; ++i){ | ^~
s186723251
p03837
C++
#include <functional> #include <climits> #include <iostream> #include <unordered_set> #include <vector> class warshall_floyd { private: int node_num; bool is_negative_graph; std::vector<std::vector<long long>> cost_matrix;//隣接行列を構築 std::vector<std::vector<int>> pred;//経路(遷移元)を保持 public: warshall_floyd(const int node_num, const std::vector<std::vector<long long>> &adj_matrix); bool get_is_negative_graph() const; bool get_is_negative_pass(int start, int end) const; long long get_cost(int start, int end) const; std::vector<int> get_min_path(int start, int end) const; }; warshall_floyd::warshall_floyd(const int node_num, const std::vector<std::vector<long long>> &adj_matrix) : cost_matrix(adj_matrix), node_num(node_num), is_negative_graph(false), pred(node_num + 1, std::vector<int>(node_num + 1, INT_MAX)) { //predの初期化 for (int i = 0; i <= node_num; i++) { for (int j = 0; j <= node_num; j++) { if (i == j) pred[i][j] = -1; else if (adj_matrix[i][j] < LLONG_MAX) { pred[i][j] = i; } } } //ワーシャルフロイドの更新式 for (int k = 0; k <= node_num; k++) { for (int i = 0; i <= node_num; i++) { for (int j = 0; j <= node_num; j++) { if (cost_matrix[i][k] < LLONG_MAX && cost_matrix[k][j] < LLONG_MAX) { if (cost_matrix[i][k] + cost_matrix[k][j] < cost_matrix[i][j]) { cost_matrix[i][j] = cost_matrix[i][k] + cost_matrix[k][j]; pred[i][j] = pred[k][j]; } } } } } for (int i = 0; i <= node_num; i++) { cost_matrix[i][i] = 0; } //負のサイクル検出 for (int i = 0; i <= node_num; i++) { //自分への距離が負になるならその頂点は負のサイクルに含まれる if (cost_matrix[i][i] < 0) { for (int j = 0; j <= node_num; j++) { //負のサイクルに含まれる頂点から辿れる頂点も負のサイクルになる if (i == j) continue; if (cost_matrix[i][j] < LLONG_MAX && cost_matrix[j][j] >= 0) cost_matrix[j][j] = -1; } is_negative_graph = true; //break; } } } bool warshall_floyd::get_is_negative_graph() const { return is_negative_graph; } bool warshall_floyd::get_is_negative_pass(int start, int end) const { //startからendにたどり着けない場合はfalseを返す if (cost_matrix[start][end] < LLONG_MAX) { //startからend辿りつける場合、 //endが負のサイクルに含まれるならtrueを返す if (cost_matrix[end][end] < 0) return true; } return false; } long long warshall_floyd::get_cost(int start, int end) const { return cost_matrix[start][end]; } std::vector<int> warshall_floyd::get_min_path(int start, int end) const { int node = end; std::vector<int> vec; vec.push_back(node); //終点から始点までの経路をたどる while (1) { //負のサイクルを含む頂点or //始点から辿れない頂点or //始点であれば終了 if (cost_matrix[node][node] < 0 || pred[start][node] >= INT_MAX || pred[start][node] == -1) break; node = pred[start][node]; vec.push_back(node); } std::reverse(vec.begin(), vec.end()); return vec; } int main() { int N, M; std::cin >> N >> M; std::vector<std::vector<long long>> adj_matrix(N + 1, std::vector<long long>(N + 1, LLONG_MAX)); std::vector<int> edge_num(N + 1, 0); for (int j = 0; j < M; j++) { long long a, b, c; std::cin >> a >> b >> c; adj_matrix[a][b] = c; adj_matrix[b][a] = c; edge_num[a]++; edge_num[b]++; } std::vector<std::vector<bool>> is_used(N + 1, std::vector<bool>(N + 1, false)); warshall_floyd wf(N, adj_matrix); int count = 0; for (int i = 1; i <= N; i++) { for (int j = i + 1; i <= N; i++) { if (adj_matrix[i][j] == LLONG_MAX) continue; if (wf.get_cost(i, j) != adj_matrix[i][j]) { count++; } } } std::cout << count << std::endl; }
a.cc: In member function 'std::vector<int> warshall_floyd::get_min_path(int, int) const': a.cc:111:14: error: 'reverse' is not a member of 'std' 111 | std::reverse(vec.begin(), vec.end()); | ^~~~~~~
s623298921
p03837
C++
#include <functional> #include <climits> #include <iostream> #include <unordered_set> class warshall_floyd { private: int node_num; bool is_negative_graph; std::vector<std::vector<long long>> cost_matrix;//隣接行列を構築 std::vector<std::vector<int>> pred;//経路(遷移元)を保持 public: warshall_floyd(const int node_num, const std::vector<std::vector<long long>> &adj_matrix); bool get_is_negative_graph() const; bool get_is_negative_pass(int start, int end) const; long long get_cost(int start, int end) const; std::vector<int> get_min_path(int start, int end) const; }; warshall_floyd::warshall_floyd(const int node_num, const std::vector<std::vector<long long>> &adj_matrix) : cost_matrix(adj_matrix), node_num(node_num), is_negative_graph(false), pred(node_num + 1, std::vector<int>(node_num + 1, INT_MAX)) { //predの初期化 for (int i = 0; i <= node_num; i++) { for (int j = 0; j <= node_num; j++) { if (i == j) pred[i][j] = -1; else if (adj_matrix[i][j] < LLONG_MAX) { pred[i][j] = i; } } } //ワーシャルフロイドの更新式 for (int k = 0; k <= node_num; k++) { for (int i = 0; i <= node_num; i++) { for (int j = 0; j <= node_num; j++) { if (cost_matrix[i][k] < LLONG_MAX && cost_matrix[k][j] < LLONG_MAX) { if (cost_matrix[i][k] + cost_matrix[k][j] < cost_matrix[i][j]) { cost_matrix[i][j] = cost_matrix[i][k] + cost_matrix[k][j]; pred[i][j] = pred[k][j]; } } } } } for (int i = 0; i <= node_num; i++) { cost_matrix[i][i] = 0; } //負のサイクル検出 for (int i = 0; i <= node_num; i++) { //自分への距離が負になるならその頂点は負のサイクルに含まれる if (cost_matrix[i][i] < 0) { for (int j = 0; j <= node_num; j++) { //負のサイクルに含まれる頂点から辿れる頂点も負のサイクルになる if (i == j) continue; if (cost_matrix[i][j] < LLONG_MAX && cost_matrix[j][j] >= 0) cost_matrix[j][j] = -1; } is_negative_graph = true; //break; } } } bool warshall_floyd::get_is_negative_graph() const { return is_negative_graph; } bool warshall_floyd::get_is_negative_pass(int start, int end) const { //startからendにたどり着けない場合はfalseを返す if (cost_matrix[start][end] < LLONG_MAX) { //startからend辿りつける場合、 //endが負のサイクルに含まれるならtrueを返す if (cost_matrix[end][end] < 0) return true; } return false; } long long warshall_floyd::get_cost(int start, int end) const { return cost_matrix[start][end]; } std::vector<int> warshall_floyd::get_min_path(int start, int end) const { int node = end; std::vector<int> vec; vec.push_back(node); //終点から始点までの経路をたどる while (1) { //負のサイクルを含む頂点or //始点から辿れない頂点or //始点であれば終了 if (cost_matrix[node][node] < 0 || pred[start][node] >= INT_MAX || pred[start][node] == -1) break; node = pred[start][node]; vec.push_back(node); } std::reverse(vec.begin(), vec.end()); return vec; } int main() { int N, M; std::cin >> N >> M; std::vector<std::vector<long long>> adj_matrix(N + 1, std::vector<long long>(N + 1, LLONG_MAX)); std::vector<int> edge_num(N + 1, 0); for (int j = 0; j < M; j++) { long long a, b, c; std::cin >> a >> b >> c; adj_matrix[a][b] = c; adj_matrix[b][a] = c; edge_num[a]++; edge_num[b]++; } std::vector<std::vector<bool>> is_used(N + 1, std::vector<bool>(N + 1, false)); warshall_floyd wf(N, adj_matrix); int count = 0; for (int i = 1; i <= N; i++) { for (int j = i + 1; i <= N; i++) { if (adj_matrix[i][j] == LLONG_MAX) continue; if (wf.get_cost(i, j) != adj_matrix[i][j]) { count++; } } } std::cout << count << std::endl; }
a.cc: In member function 'std::vector<int> warshall_floyd::get_min_path(int, int) const': a.cc:109:14: error: 'reverse' is not a member of 'std' 109 | std::reverse(vec.begin(), vec.end()); | ^~~~~~~