prompt string | response string |
|---|---|
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | n = int(input())
m = int(input())
dp = [[float('inf') for _ in range(n)] for _ in range(n)]
for i in range(n):
dp[i][i] = 0
for _ in range(m):
a, b, c, d = map(int, input().split(','))
dp[a - 1][b - 1] = c
dp[b - 1][a - 1] = d
for k in range(n):
for i in range(n):
for j in range(n):
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
using namespace std;
int main()
{
int n;
for(;cin>>n;)
{
int edge[n][n],m;
cin>>m;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{
if(i==j)
edge[i][j]=0;
else
edge[i][j]=1000000;
}
for(int i=0;i<m;i++)
{
char ch;
int a,b,c,d;
cin>>a>>ch... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #if 0
#endif
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int N, M, A, B, C, D, S, G, V, P;
int K[32][32];
const int Inf = 1000000100;
int main() {
scanf("%d%d", &N, &M);
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++)
K[i][j] = Inf;
}
for (int i=0; i<M; ++i)... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | # The question itself is not diffifult, but the website only
# tested my code with two cases, so I am not sure whether the
# "accepted" is trustworthy.
# Note: math.inf > math.inf -> False
import math
V = int(input())
E = int(input())
fees = [[math.inf] * V for i in range(V)]
for i in range(V):
fees[i][i] = 0
for... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
long long d[21][21],y1,y2,c1,d1;
int i,j,k,m,n,a1,b1,x1,x2;
cin >> n;
for (i=1;i<=n;i++) for (j=1;j<=n;j++) if (i==j) d[i][j]=0; else d[i][j]=99999999999999;
cin >> m;
for (i=0;i<m;i++) {
scanf("%d,%d,%lld,%lld",&a1,&b... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0117
AC
"""
import sys
from sys import stdin
input = stdin.readline
def warshallFloyd(V, dp):
for k in range(V):
for i in range(V):
for j in range(V):
if dp[i][k] + dp[k][j] < dp[i][j]:
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | from heapq import heappush, heappop
def solve():
N = int(input())
M = int(input())
G = [[] for i in range(N)]
for i in range(M):
a, b, c, d = map(int, input().split(","))
G[a-1].append((b-1, c))
G[b-1].append((a-1, d))
s, g, V, P = map(int, input().split(","))
INF = 10**1... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
int m = sc.nextInt();
int[] cost = new int[n+1];
for(int i=0;i<n+1;i++) cost[i] = Integer.MAX_VALUE;
int[] a = new int[m+1];
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
using namespace std;
int N,M,A,B,C,D,x1,x2,y1,y2;
const int inf=1000000000;
int K[32][32];
int main(){
for(int i=0;i<32;i++){
for(int j=0;j<32;j++){
if(i==j){
K[i][j]=0;
}else{
K[i][j]=inf;
}
}
}
scanf("%d%d",&N,&M);
for(int i=0;i<M;i++){
scanf("%d,%d,%... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import sys
def dijkstra(nodes, start, goal, matrix):
defnode = [False] * (nodes+1)
cost = [sys.maxint] * (nodes+1)
cost[start] = 0
node = start
while True:
defnode[node] = True
for i in xrange(1, nodes+1):
if defnode[i]:
continue
if matrix[node][i] == sys.maxint:
continue
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | INF = 1000000
def bellman_ford(graph, source):
lg = len(graph)
unused = list(range(lg))
d = [INF] * (lg)
d[source] = 0
while unused:
v = min(unused, key=lambda u: d[u])
unused.remove(v)
for u in range(n + 1):
d[u] = min(d[u], d[v] + graph[v][u])
return d
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <cstdio>
#include <cstring>
#define M(a,b) (a<b?a:b)
#define F(i,n) for(int i=0;i<n;i++)
int n,m,a,b,c,d,e[20][20];int main(){memset(e,31,1600);scanf("%d%d",&n,&m);F(i,m){scanf("%d,%d,%d,%d",&a,&b,&c,&d);a--;b--;e[a][b]=c;e[b][a]=d;}scanf("%d,%d,%d,%d",&a,&b,&c,&d);a--;b--;F(k,n)F(i,n)F(j,n) e[i][j] = M(e[i][j... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int inf = 100000000;
int main(){
int n,m,s,g,V,P,K[210][210],a,b,c,d;
cin >> n >> m;
for(int i = 0;i < 210;i++){
for(int j = 0;j < 210;j++){
K[i][j] = inf;
}
}
for(int i... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<climits>
using namespace std;
int main(){
int n,sum,m,dp[30][30],a,b,c,d,now,tar,mon,pri;
cin>>n;
cin>>m;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++){
if(i!=j)
dp[i][j]=INT_MAX/2;
else
dp[i][j]=0;
}
for(int i=0;i<m;i++){
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
dp[a-1][b-1]=c;
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
using namespace std;
int cost[22][22]={0};
int main(){
int n,m,i,j,k,a,b,c,d;
char cc;
cin>>n>>m;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
cost[i][j] = 1<<28;
for(i=0;i<m;i++){
cin>>a>>cc>>b>>cc>>c>>cc>>d;
cost[a][b]=c;cost[b][a]=d;
}
fo... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int n, m, reward;
int a, b, c, d;
int x1, x2, y1, y2;
int cost[21][21];
char ch;
cin >> n >> m;
for (int i = 0; i < 21; i++)
{
for (int j = 0; j < 21; j++)
{
cost[i][j] = 10000; //????°?????????¨????????????... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
public class Main {
int N,M,s,g,V,P;
ArrayList<Integer>[] graph;
int[][] cost;
private class P implements... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int N,M,A,B,C,D;
const int inf = 100000;
int main()
{
cin >> N >> M;
int K[32][32];
for(int i = 1; i < N+1; i++)
{
for(int j = 1; j < N+1; j++)
{
K[i][j] = inf;
}
}
for(int i = 0; i < M; i++)
{
scanf("%d,%d,%d,%d", &A, &B,... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<cstdio>
#include<functional>
#include<algorithm>
#define MM 200000000
using namespace std;
int main(void)
{
int n,m,i,j,k,a,b,c,d,mi[21][21],s,g,v,p,sum;
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++) {
for(j=1;j<=n;j++) {
if(i==j) mi[i][j]=0;
else mi[i][j]=MM;
}
}
for(i=0;i<m;i++) {
scanf("%d,%d,%d,... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | n= int(input())
m=int(input())
inf=1001001001
data =[[inf]*n for i in range(n)]
for i in range(m):
a,b,c,d= map(int,input().split(","))
data[a-1][b-1]= c
data[b-1][a-1]= d
s,g,V,P = map(int,input().split(","))
for k in range(n):
for i in range(n):
for j in range(n):
if data[i][j]>d... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
int d[22][22];
int V;
int inf=10000000;
void warshall_floyd(){
for(int k=0; k<V; k++){
for(int i=0;i... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
signed int n, m, a, b, c, d;
char temp[3];
cin >> n >> m;
vector<vector<int>> map(n, vector<int>(n, 2000000));
for(int i = 0;i<m;i++){
cin >> a >> temp[0] >> b >> temp[1] >> c >> te... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)
int main()
{
int wf[20][20];
int n,m,a,b,c,d;
/*ú»*/
rep(i,20)
rep(j,20)
wf[i][j] = INF;
rep(i,20)
wf[i][i] = 0;
/*üÍ*/
cin >> n >> m;
rep(i,m){
scanf("%d,%d,%d,%d\n",&a,&b,&... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
int main(){
int n,a,b,c,d,M[22][22],i,j,k;
std::cin>>n>>k;
for(i=0;i++<n;)for(j=0;j++<n;)M[i][j]=1<<29;
for(;k+1;){
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
if(k--){M[a][b]=c;M[b][a]=d;}
}
for(k=0;k++<n;)for(i=0;i++<n;)for(j=0;j++<n;)
M[i][j]=std::min(M[i][j],M[i][k]+M[k][j]);
prin... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define INF 147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
//war... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | // AOJ 0117 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0117)
#include<cstdio>
#include<algorithm>
#include<limits>
#define rep(i,a) for(int i=0;i<(a);++i)
const int MAX_N = 20, INF = std::numeric_limits<int>::max()>>4;
int n, m;
int d[MAX_N][MAX_N];
int x1, x2, Y1, y2;
int main()
{
scanf( "%d%d", &n,... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | n = int(input())
m = int(input())
cost = []
for i in range(n):
t = [float('inf')]*n
t[i] = 0
cost.append(t)
for i in range(m):
s = input()
s += ','
L = []
z = ''
for j in range(len(s)):
if s[j] != ',':
z += s[j]
else:
L.append(int(z))
z... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <sstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
int n,m,d[21][21],s,g,pr,pi;
const int INF=9999999;
char com;
s... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;
const int MAX_V = 51;
int d[MAX_V][MAX_V];
int V;
void warshall_floyd() {
for ( int k = 0; k < V; k++ ) {
for (int i = 0; i < V; i++ ) {
for ( int j = 0; j < V; j++ ) {
d[i][j] = min(d[i][j], d[i][k] + d[k][j] );
}
}
}
}... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
using namespace std;
int main(){
int cost[22][22]={0};
int n,m,i,j,k,a,b,c,d;
char cc;
cin>>n>>m;
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
cost[i][j] = 1001001;
}
}
for(i=0;i<m;i++){
cin>>a>>cc>>b>>cc>>c>>cc>>d;
cost[a][b]=c;cos... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import java.util.Scanner;
public class Main {
int d[];
boolean used[];
int g[][];
final int INF = 1 << 28;
int die(int s, int e, int n){
used = new boolean[n];
d = new int[n];
for(int j=0; j<n; ++j){ d[j] = INF; }
d[s] = 0;
while(true){
int u = -1;
for(int v=0; v<n; ++v){
if(!used[v] ... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import heapq
def dijkstra(start,goal,graph):
INF = 2 << 20
node_num = len(graph)
visited = [False] * node_num
costs = [INF] * node_num
pq = []
costs[start] = 0
heapq.heappush(pq, [0,start])
while not len(pq) == 0:
cur_cost,cur_node = heapq.heappop(pq)
if visited[cur_no... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <sstream>
#include <algorithm>
#define INF 1<<27
using namespace std;
int V,E;
int cost[301][301];
bool used[301];
int d[301];
void init(){
fill(d,d + 101,INF);
fill(used,used + 101,false);
}
void dijkstra(int s){
init();
d[s] = 0;
while(1){
int v = -1;
for(int i = 1 ; ... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<bits/stdc++.h>
#define LL long long int
#define INF 10000000
using namespace std;
int main(void)
{
LL i,j,k,n,m,glid[21][21],start,gorl,v[21],clr[21],a,b,c,d,mm,p,ans2,mini,x,ans1;
cin>>n>>m;
for(i=0;i<21;i++)for(j=0;j<21;j++) glid[i][j]=INF;
for(i=0;i<m;i++) {
scanf("%lld,%lld,%lld,%lld",&a,&b,&c,&d);
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | def f(x1, x2):
W=[[i,1000] for i in range(n)]
W[x1]=[x1,0]
W[x2]=[x2,2000]
G = range(n)
while 1:
A = sorted([W[e] for e in G], key=lambda x: x[1])
p1, w1 = A[0]
G.remove(p1)
if p1==x2: break
for p2, w2 in A[1:]:
way=(p1, p2)
if way in cost:
W[p2] = [p2, min([w2, w1 + co... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <vector>
using namespace std;
#define INF 999999999
int D[21][21];
void solve()
{
int n, m;
cin >> n >> m;
for(int i = 0; i < n; ++i)
{
for(int j = 0; j < n; ++j)
{
i == j ? D[i][i] = 0 : D[i][j] = INF;
}
}
for(int i = 0; i < m; ++i)
{
int a, b, c, d;
scanf("%d,%d,%d,%... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstring>
using namespace std;
int n,m;
int t[22][22];
int main(void){
memset(t,-1,sizeof(t));
cin>>n>>m;
for(int i=0;i<m;i++){
char ch;
int a,b,c,d;
cin>>a>>ch>>b>>ch>>c>>ch>>d;
a--;
b--;
t[a][b] = c;
t[b][a] = d;
}
char ch;
int s,d,x,y;
cin>>s>>ch>>d>>ch>>x>>ch>>y;
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <cstdio>
#define INF 10000000
int n,m,x1,x2,y1,y2;
int fee[21][21];
int ans[21][21];
int main(){
scanf("%d %d",&n,&m);
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
fee[i][j] = i==j?0:INF;
}
}
for(int i=0; i<m; i++){
int a,b,c,d;
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
fee[a... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <bits/stdc++.h>
using namespace std;
int main(){
long long int cost[21][21];
int n,m;
char com;
cin>>n>>m;
for(int i=0;i<21;i++){
for(int j=0;j<21;j++){
cost[i][j]=1<<27;
}
}
for(int i=0;i<m;i++){
int a,b,c,d;
cin>>a>>com>>b>>com>>c>>com>>d;
cost[a][b]=c;cost[b][a]=d;
}
for(int k=1;k<=n;k... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt(), m=sc.nextInt();
int[][] map = new int[n+1][n+1];
for(int[] tmp : map) Arrays.fill(tmp,-1);
for(int i=0;i<m;i++){
String[] s = sc.next().split(",");
int a=Integer.pa... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
#define size 32
using namespace std;
int N,M,A,B,C,D,x1,x2,y1,y2;
int cost;
int K[size][size];
const int inf = 1001001001;
int main(){
for(int i=1; i<size ; i++){
for(int j=1 ; j<size ; j++){
K[i][j]=inf;
}
}// 行列初期化
scanf("%d %d",&N,&M);
for(int i=0; i< M ;++i){
scan... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
int n, m, a, b, c, d;
int data[25][25];
int start, end, money, price;
for (int i = 0; i < 25; i++){
for (int j = 0; j < 25; j++){
data[i][j] = 10000000;
}
}
cin >> n >> m;
for (int i = 0; i < m; i++){
scanf("%d,%d,%d,%d", &... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int dp[30][30];
int n, m, s, g, V, P;
void warshallFloyd() {
for (int k = 0; k < n; k++)
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
}
int main(void) ... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
private static BufferedReader br = null;
private static int[][] map = null;
private static int stp = 0;
private static int edp = 0;
private static int mon = 0;
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
int main(){int n,a,b,c,d,M[22][22],i,j,k;std::cin>>n>>k;for(i=0;i++<n;)for(j=0;j++<n;)M[i][j]=1<<29;for(;scanf("%d,%d,%d,%d",&a,&b,&c,&d),k+1;)if(k--){M[a][b]=c;M[b][a]=d;}for(k=0;k++<n;)for(i=0;i++<n;)for(j=0;j++<n;)M[i][j]=std::min(M[i][j],M[i][k]+M[k][j]);printf("%d\n",c-d-M[a][b]-M[b][a]);} |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <algorithm>
#define MAX_N 20
#define INF 1e9
using namespace std;
int dp[MAX_N][MAX_N];
int n,m;
void warshall_froyd(){
for(int k=0;k<n;k++){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
}
}
}
}
int main(){
c... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
using namespace std;
static const int INF = 1<<21;
int n, m, a, b, c, d, s, g, v, p;
int mat[21][21];
void floyd(){
for(int k = 1; k <= n; k++){
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
mat[i][j] = min(mat[i][j], mat[i][k]+mat[k][j]);
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <bitset>
#include <climits>
using namespace std;
typedef long long ll;
int main(){
int N, M, st, A, B, C, D, X1, X2, Y1, Y2;
int K[20][20];
for(int i=0;i<20;++i){
for(int j=0;... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<climits>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<set>
#include<stack>
#include<functional>
#include<queue>
using namespace std;
int main(){
int N,M,A,B,C1,C2,d[20][20],S,G,Mny,V;
fill_n((int*)d,2... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
using namespace std;
#define MAX 21
#define INF 9999999
int main(){
int mm[MAX][MAX],n,m,a,b,c,d,x1,x2,y1,y2;
cin >> n >> m;
for(int i = 1 ; i <= n ; i++)
for(int j = 1 ; j <= n ; j++)
mm[i][j] = INF;
while(m--){
scanf("%d,%d,%... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
using namespace std;
int N, M, A, B, C, D, x1, x2, y1, y2;
int K[32][32];
const int inf = 1001001001;
int main() {
scanf("%d%d", &N, &M);
for (int i=1; i<=N; ++i) {
for (int j=1; j<=N; ++j) {
K[i][j] = inf;
}
}
for (int i=0; i<M; ++i) {
scanf("%d,%d,%d,%d", &A, &B, &C,... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <cstdio>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, n)
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF (1 << 20)
int g[20][20];
int main()
{
int n, m; scanf("%d%d", &n, &m);
rep(i, n) rep(j, n) g[i][j] = INF;
rep(i, m) {
int p, q, r, s;
sc... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)
int main() {
int n, m;
int dis[20][20];
cin >> n >> m;
fill(dis[0], dis[20], INF);
REP(i, n) dis[i][i] = 0;
REP(i, m) {
int a, b, c, d;
scanf("%d,%d,%d,%d", &a, &b, ... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | n=int(input())
m=int(input())
l=[]
for i in range(m):
l1=list(map(int,input().split(",")))
l.append(l1)
s,g,v,p=map(int,input().split(","))
listl=[[100000 for i in range(n+1)] for i in range(n+1)]
for i in l:
listl[i[0]][i[1]]=i[2]
listl[i[1]][i[0]]=i[3]
for i in range(1,n+1):
for j in range(1,n+1):
for k... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
using namespace std;
int main(){
int cost[22][22]={0};
int n,m,i,j,k,a,b,c,d;
char cc;
cin>>n>>m;
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
cost[i][j] = 28;
}
}
for(i=0;i<m;i++){
cin>>a>>cc>>b>>cc>>c>>cc>>d;
cost[a][b]=c;cost[b][... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
using namespace std;
int main(){
int cost[22][22]={0};
int n,m,i,j,k,a,b,c,d;
char cc;
cin>>n>>m;
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
cost[i][j] = 1<<28;
}
}
for(i=0;i<m;i++){
cin>>a>>cc>>b>>cc>>c>>cc>>d;
cost[a][b]=c;cost[... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <algorithm>
using namespace std;
const int INF = 10000000;
int n,m;
int data[101][101];
void warshall_floyd() {
for ( int k = 0; k <= n; k++ ) {
for (int i = 0; i <= n; i++ ) {
for ( int j = 0; j <= n; j++ ) {
data[i][j] = min( data[i][j], data[i][k] + data[k][j] );
}
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
using namespace std;
int main(){
const int nmax = 21;
int route[nmax][nmax];
int n;
int m;
int a, b, c, d;
int x1, x2, y1, y2;
char ch;
int cost1, cost2;
cin >> n >> m;
for(int i = 0; i < nmax; i++){
for(int j = 0; j < nmax; j++){
route[i][j] = -1;
}
}
for(int i = 0; i < m; i++){... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<cstdio>
#include<algorithm>
#define INF 1111111
using namespace std;
int N;
int A[100][100];
void floyd(){
for(int k=0;k<=N;k++)
for(int i=0;i<=N;i++)
for ( int j=0;j<=N;j++)
A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
}
int main(void){
int m,a,b,c,d,x1,x2,y1,y2;
scanf("%d",&N);
for(int i=0;i<=N;i... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
using namespace std;
int main(){
int cost[22][22]={0};
int n,m,i,j,k,a,b,c,d;
char cc;
cin>>n>>m;
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
cost[i][j] = 1<<28;
}
}
for(i=0;i<m;i++){
cin>>a>>cc>>b>>cc>>c>>cc>>d;
cost[a][b]=c;cost[... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <algorithm>
#include <iostream>
using namespace std;
/** Problem0117 : A reward for a Carpenter **/
const int INF = 100000;
int main()
{
int d[21][21];
int V, E;
int s, g, plus, minus;
char c;
cin >> V >> E;
for (int i=0; i<21; i++)
for (int j=0; j<21; j++) d[i][j] = INF;
for (int i=0; i<E; i+... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
int n,m;
int a,b,c,d;
int st,go;
int hi,yo;
int road[1111][1111];
cin >> n >> m;
for(int i=0;i<n;i++){//ありえない大きさの数を入れておく
for(int j=0;j<n;j++){
road[i][j]=8478;
}
}
for(int i=0;i<m;i++){//エッジそれぞれにと... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
struct edge{
int city1,city2,cost1to2,cost2to1;
};
int main(){
int n=0,m=0,start=0,goal=0,budget=0,treecost=0;
cin>>n>>m;
edge node[m+1];
for(int i=1;i<=m;i++){
scanf("%d,%d,%d,%d",&node[i].city1,&node[i].city2,&node[i].cost1to2,&node[i... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
const int INF=100000;
using namespace std;
int main(void){
int list[21][21];
int n,m;
int a,b,c,d;
int x,y,z,w;
int i,j,k;
int cost;
for(i=0;i<21;i++){
fill(list[i],list[i]+21,INF);
}
scanf("%d",&n);
scanf("%d",&m);
f... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<algorithm>
#include<iostream>
#include<cstdio>
const int INF = 1001;
int n, m;
int dist[20][20];
int s, e, x, y;
int main()
{
for( int i = 0; i != 20; ++i )
for( int j = 0; j != 20; ++j )
dist[i][j] = i == j ? 0 : INF;
std::cin >> n >> m;
for( int i = 0; i != m; ++i )
{
int a, b, c, d;
scan... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<cstdio>
using namespace std;
#define REP(i, n) for(int i=0; i<n; i++)
#define REP1(i, n) for(int i=0; i<n; i++)
int INF = 10e8;
int n, m;
int dis[21][21];
int s, g, v, p;
int main(){
cin >> n >> m;
REP(i, n+1){
REP(j, n+1){
if(i!=0 && i==j){
d... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<cstdio>
using namespace std;
int n,m,a,b,c,d,s,g,v,p,K[30][30];
const int inf=10000000;
int main(){
for(int i=0;i<30;i++){
for(int j=0;j<30;j++){K[i][j]=inf;}
}
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++){
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
//cout<<a<<b... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <vector>
using namespace std;
int main()
{
int n,m,a,b,c,d,x1,x2,y1,y2;
char ch;
cin >> n >> m;
vector< vector<int> > road(n+1,vector<int>(n+1,100001));
for (int i = 0; i < m; i++) {
cin >> a >> ch >> b >> ch >> c >> ch >> d;
road[a][b] = c;
road[b][a] = d;
}
for (int k = 1; k... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... |
#include<iostream>
#include<cstdio>
#include<algorithm>
#define INF 1000000000
using namespace std;
int d[20];
int cost[20][20];
bool done[20];
int N, M, x1, x2, y1, y2;
void dj(int s)
{
fill(d, d + 20, INF);
fill(done, done + 20, 0);
d[s] = 0;
while(1)
{
int v = -1;
for(int i = 0; i < N; i++)
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
using namespace std;
int N, M, A, B, C, D, x1, x2, y1, y2;
int K[30][30];
int ans;
const int infty = 10000000;
int main() {
// 初期化
for (int i=0; i<30; i++) {
for (int j=0; j<30; j++) {
K[i][j] = infty;
}
}
// 入力
scanf("%d%d", &N, &M);
for (int i=0; i<M; ... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
using namespace std;
int N, M, A, B, C, D, x1, x2, y1, y2;
const int inf = 1001000100;
int K[32][32]={};
int main() {
scanf("%d%d", &N, &M);
for (int i=1; i<N+1; i++)
for (int j=1; j<N+1; j++)
K[i][j] = inf;
for (int i=0; i<M; ++i){
scanf("%d,%d,%d,%d", &A... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
using namespace std;
int n;
int s[21]={0};
int d[21][21]={... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
static int city_number, way_number;
static int[][] way;
static int[] Array = new int[4];
static int start, goal, reward, cost;
static final int INF = 10000000;
/**
* @param args
*/
public static void main(String[] args) {
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
using namespace std;
#define REP(i,n) for(int i=0; i<n; i++)
int main()
{
char c;
int x1,x2,y1,y2;
int n,m,a,b,ab,ba;
int tb[32][32];
cin >> n >> m;
REP(i,n)REP(j,n)
{
tb[i][j] = (i==j ? 0 : 1<<20);
}
while(m--)
{
cin >> a >> c >> b >> c >> ab >> c >> ba;
a--; b--;
tb[a][b] = a... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <bits/stdc++.h>
using namespace std;
int main(){
int n, m;
scanf("%d", &n);
scanf("%d", &m);
int E[n][n], F[n][n];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(i == j) E[i][j] = 0;
else E[i][j] = 1e9;
}
}
for(int i = 0; i ... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define INF 1 << 16
using namespace std;
int main(){
int cost[20][20]; fill(&cost[0][0], &cost... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... |
machi_number = input()
road_number = input()
mapp = [[10000 for j in range(machi_number)] for i in range(machi_number)]
for i in range(road_number):
a,b,c,d =map(int, raw_input().split(","))
aa = a-1
bb = b-1
mapp[aa][bb] = c
mapp[bb][aa] = d
for i in range(machi_number):
mapp[i][i] = 0
for k in range(machi_n... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | n = int(input())
m = int(input())
K = [[float('inf') for i in range(n)] for j in range(n)]
#print(K)
for i in range(m):
a,b,c,d = map(int,input().split(','))
#print(a,b,c,d)
K[a-1][b-1] = c
K[b-1][a-1] = d
for k in range(n):
for i in range(n):
for j in range(n):
if K[i][j] > K[i]... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | def f(x1, x2):
W=[[i,1000] for i in range(n)]
W[x1]=[x1,0]
W[x2]=[x2,2000]
G = range(n)
while 1:
A = sorted([W[e] for e in G], key=lambda x: x[1])
p1, w1 = A[0]
G.remove(p1)
if p1==x2: break
for p2, w2 in A[1:]:
way=(p1, p2)
if way in cost: W[p2] = [p2, min([w2, w1+cost[way]])]... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import java.util.Arrays;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
while(in.hasNext())
{
int n=in.nextInt();
int m=in.nextInt();
int M=1000000;
int road[][]=new int[n+1][n+1];
for(int i=0;i<=n;i++)
Arrays.fill(ro... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<algorithm>
using namespace std;
int cost[20][20];
int main(){
int n,m;
cin>>n>>m;
for(int i=0;i<20;i++)for(int j=0;j<20;j++)cost[i][j]=1<<29;
for(int i=0;i<20;i++)cost[i][i]=0;
for(int i=0;i<m;i++){
int a,b,c,d;
cin>>a;
cin.ignore();
cin>>b;
cin.ignore();
cin>>c;
cin.ign... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
#include <cmath>
#define INF 100000000
using namespace std;
int main(){
int d[20][20];
int n,m,s,g,v,p;
cin >> n >> 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++){
int a,b,c,e;
scanf("%d,%d,%d,%d",&a,&b,&c... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int N, M; scanf("%d%d", &N, &M);
static int wf[20][20];
for(int i = 0; i < N; i++)
for(int j = 0; j < N; j++)
wf[i][j] = 1000000000;
for(int i = 0; i < M; i++) {
int a,b,c,d; scanf("%d,%d,%d,%d", &a, &b, &c... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import java.util.Arrays;
import java.util.Scanner;
public class Main{
public static void main(String[] args){
new Main().run();
}
int[][] cost;
boolean[] visit;
int[] dist;
int n;
public void run(){
Scanner scan = new Scanner(System.in);
while(scan.hasNext()){
n = scan.nextInt();
int m = sca... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | n = int(input())
m = int(input())
roads = [[float('inf') for _ in range(n)] for _ in range(n)]
for _ in range(m):
a,b,c,d = map(int, input().split(','))
roads[a-1][b-1] = c
roads[b-1][a-1] = d
s,g,V,P = map(int, input().split(','))
for k in range(n):
for i in range(n):
for j in range(n):
... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i++)
int main(void){
int maze[20][20];
int maze1[20][20];
int prv[20][20];
int n,m;
int a,b,c,d;
cin>>n>>m;
rep(i,n)rep(j,n)maze[i][j]=maze1[i][j]=10000000;
while(m--){
scanf("%d,%d,... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
using namespace std;
int N, M, A, B, C, D, x1, x2, y1, y2;
int K[32][32];
int mini(int s,int t){
if(s>t){
return t;
}
return s;
}
int main(){
for (int i = 0; i < 32; ++i)
{
for (int j = 0; j < 32; ++j)
{
K[i][j]=100100100;
}
}
scanf("%d%d", &N... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import heapq
def dijkstra(start,goal,graph):
INF = 2 << 20
node_num = len(graph)
visited = [False] * node_num
costs = [INF] * node_num
pq = []
costs[start] = 0
#print costs[start]
heapq.heappush(pq, [0,start])
while not len(pq) == 0:
cur_cost,cur_node = heapq.heappop(p... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | n = int(input())
m = int(input())
mat = [[float("inf")]*n for _ in [0]*n]
for a,b,c,d in((map(int, input().split(","))) for _ in [0]*m):
mat[a-1][b-1] = c
mat[b-1][a-1] = d
s,g,v,p = map(int, input().split(","))
for k in range(n):
for i in range(n):
for j in range(n):
mat[i][j] = min(mat... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import java.util.*;
import java.io.*;
import static java.lang.Math.*;
class Pair implements Comparable<Pair> {
final int cost;
final int to;
Pair( int cost, int to ) {
this.cost = cost;
this.to = to;
}
public int compareTo( Pair p ) {
return cost - p.cost;
}
}
class Main {
publi... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... |
import java.awt.geom.Point2D;
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.NoSuchElementE... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
// TODO ?????????????????????????????????????????????
BufferedReader br = new BufferedReader... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
using namespace std;
int main(){
char c;
long n,m,a,b,d,e,f,i,j,k,p[20][20],x1,x2,y1,y2,q[20];
cin>>n>>m;
for(i=0;i<m;i++){
q[i]=-1;
for(j=0;j<n;j++)p[i][j]=-1;
}
for(i=0;i<m;i++){
cin>>a>>c>>b>>c>>d>>c>>e;
p[a-1][b-1]=d;
p[b-1][a-1]=e;
}
cin>>x1>>c>>x2>>c>>y1>>c>>y2;
q[x1-1]=0;
for(k=0;k<n;k++){
f=0... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<cstdio>
const int INF=100100100;
using namespace std;
int n,m;
int K[32][32];
int main(){
scanf("%d%d", &n,&m);
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
K[i][j]=INF;
}
}
int a,b,c,d;
for(int i=0;i<m;i++){
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
K[a][b]=c;... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | from heapq import heappop, heappush
def solve(graph,start,goal,numnodes):
que = []
heappush(que,(0,start-1))
mindists = [float("inf")]*numnodes
while que:
ccost,cnode = heappop(que)
if mindists[cnode] < ccost: continue
for nnode,mcost in graph[cnode]:
tcost = ccost+mc... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | import copy
def discomfort(dic, n):
global expenses, c
if expenses != None and sum(p_res) >= expenses:
return
if n == c:
if n == g_n:
c = s_n
discomfort(l_dic, g_n)
c = g_n
return
else:
expenses = sum(p_res)
Pir... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
using namespace std;
typedef long long LL;
static const double EPS = 1e-9;
#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define INFINITY 100000
int cost[20][20];
int main(v... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0117
"""
import sys
from sys import stdin
input = stdin.readline
def warshallFloyd(V, dp):
for k in range(V):
for i in range(V):
for j in range(V):
dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
const int INF = 1 << 28;
int n;
while (~scanf("%d", &n)) {
int m;
scanf("%d", &m);
vector<vector<int> > cost(n, vector<int>(n, INF));
for (int i = 0; i < m; ++i) {
int a1, b1, c1, d1;
scanf("%... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<string>
#include<math.h>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;
const double INF=100000000;
int main(){
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.