output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define... | ### Prompt
Create a solution in CPP for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int mind[22][110][110];
ll ... | ### Prompt
Develop a solution in cpp to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloa... | ### Prompt
In cpp, your task is to solve the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with th... |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
int n,m,c,s,g;
int p[30], q[30][60], r[30][60];
int d_dist[30][110][110];
int d_final[110][110];
const int inf = 1e9;
inline int getcost(int dist, int *q, int *p){
if(dist == inf) ret... | ### Prompt
Your task is to create a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
const int INF = 1<<29;
int n,c;
int f[20][20001];
int dist[20][100][100];
int G[100][100];
int cost[100];
bool used[100];
typedef pair<int,int> E;
void setcost(int cp,vector<int> x,vector<int> r){
f[cp][0] = 0;
x.push_back(20000);
in... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> P;
const int inf = 1e9;
struct E{
int to, cost;
};
int n, m, c, s, g;
int d[20][100][100];
int k[20];
int p[20][51];
int q[20][50];
vector<E>... | ### Prompt
Develop a solution in Cpp to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int p[32], q[32][64], r[32][64];
int get(int dist, int station)
{
int ret = 0;
int prev = 0;
for (int i = 0; i < p[station] - 1; i++){
if (q[station][i] <= dist){
ret += r[station][i] * (q[station][i] - prev);
}
else {
re... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=ve... | ### Prompt
Please formulate a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
constexpr int inf = 1e9;
void warshall_floyd(vector<vector<int>>& d){
for(int k = 0; k < d.size(); k++){
for(int i = 0; i < d.size(); i++){
for(int j = 0; j < d.size(); j++){
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
}
}
... | ### Prompt
In cpp, your task is to solve the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with th... |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
class Edge
{
public:
int to;
ll dist;
int company;
Edge(int t,ll d,int c)
{
to=t;
dist=d;
company=c;
}
};
vector<Edge> g[100];
vector<int> q[100];
vector<int> r[100];
vector<Edge> syuku[100];//同一会社の道をマージしたグラフ
ll wf... | ### Prompt
Create a solution in Cpp for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define INF 10000000
int main() {
int n, m, c, s, g;
while (cin >> n >> m >> c >> s >> g) {
if (n == 0 && m == 0 && c == 0 && s == 0 && g == 0) {
break;
}
vector< vector< vector<long long int> > > dist(c, vect... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e12;
int p[21], q[21][51], r[21][51];
int costTable[21][100010];
int d[21][110][110];
signed main(){
int n, m, c, s, g;
while(cin >> n >> m >> c >> s >... | ### Prompt
Please create a solution in CPP to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#define INF INT_MAX>>1
using namespace std;
int main(void){
while(1){
int n, m, c, s, g;
cin >> n >> m >> c >> s >> g;
if(!n && !m && !c && !s && !g) break;
s--; g--;
static int dist[100][100][20];
for(int i=0; i<n; i++){
... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)
#define rep(i, n) REP(i, 0, n)
#define LINE /*cout << "LINE : "<< __LINE__ << endl*/
const int MAX_N = 101;
const int MAX_C = 21;
const int INF = 1e9;
int cost[MAX_N][MAX_N];
int dist[M... | ### Prompt
Please create a solution in Cpp to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <iostream>
#define inf 1000000000
#define llint long long int
using namespace std;
llint n, m, c, s, g;
llint G[25][105][105];
llint G2[105][105];
llint fee[25][10001];
llint p[25], q[25][55], r[25][55];
void warshallfloyd(llint G[105][105])
{
for(llint k = 1; k <= n; k++){
for(llint i = 1; i <= n; i++){... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
// template {{{
#include <bits/stdc++.h>
using namespace std;
#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define pb push_back
#define pf push_front
#define eb em... | ### Prompt
Please formulate a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
//C99 or C++98
#include <stdio.h>
int A[100][100],B[20][100][100];
int main(){
const int INF=1<<29;
int n,m,c,s,g;
for(;scanf("%d%d%d%d%d",&n,&m,&c,&s,&g),n;){
//?????¢??????????????????
for(int i=0;i<n;i++)for(int j=0;j<n;j++){
A[i][j]=INF;
for(int k=0;k<c;k++)B[k][i][j]=INF;
}
//?????????????????¨???... | ### Prompt
Create a solution in CPP for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
#include<iostream>
#include<vector>
#include<algorithm>
const int INF=1000000000;
using namespace std;
int main(void){
int n,m,c,s,g,x,y,d,C;
int p[21],q[21][51],r[21][51];
int graph[21][101][101],G[101][101],cost[21][20001];
while(cin >> n >> m >> c >> s >> g,n|m|c|s|g){
fill(graph[0]... | ### Prompt
Please create a solution in cpp to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
#define INF 1LL<<40
int N, M, C, S, G;
ll d[20][100][100];
int P[20];
int Q[20][50];
int R[20][50];
ll dd[100][100];
ll getCost(int c, ll dist)
{
if (P[c] == 1) return dist * R[c][0];
if (dist <= Q[c][0]) re... | ### Prompt
Construct a CPP code solution to the problem outlined:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with ... |
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1000000007;
static int cost[20][100][100];
int main(){
int n, m, c, s, g;
while(cin >> n >> m >> c >> s >> g, n){
for(int i=0;i<c;i++)
for(int j=0;j<n;j++)
for(int k=0;k<n;k++)
cost[i][j][k] = j==k ? 0 : INF;
for(int i=0;i<... | ### Prompt
Please formulate a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#define INF INT_MAX>>1
using namespace std;
int main(void){
while(1){
int n, m, c, s, g;
cin >> n >> m >> c >> s >> g;
if(!n && !m && !c && !s && !g) break;
s--; g--;
static int dist[100][100][20];
for(int i=0; i<n; i++){
... | ### Prompt
Please create a solution in Cpp to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
/*
Railway Connection(https://onlinejudge.u-aizu.ac.jp/problems/1182)
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algori... | ### Prompt
Generate a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the s... |
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x... | ### Prompt
Your task is to create a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int, int>P;
struct edge { int from, to, cost; };
int p[20], q[20][55], r[20][55], d[100], k[100][100], sum[20][55];
int main() {
int n, m, c, s, g;
while (scanf("%d%d%d%d%d", &n, &m, &c, &s, &g), n... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;
#define fi first
#define se second
typedef pair<int,int> pii;
const int INF = 1e9;
struct edge {
int x, y;
int d;
edge(int x_, int y_, int d_) {
x = x_; y = y_; d = d_;
}
};
int main() {
int N, M, C, S, G;
whi... | ### Prompt
Generate a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the s... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n,m,c,s,g;
const int INF = 1e9+9;
int dist[25][105][105];
int val[105][105];
int p[25];
int dtov[25][20005];
int dij(int ss, int gg){
bool done[105];
int d[105];
for(int i=0;i<n;i++)
d[i] = INF;
for(int i=0;i<n;i++)
done[i] = false;
d... | ### Prompt
Please create a solution in Cpp to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include"bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = b - 1; i >= a; i--)
#define RREP(i, n) RFOR(i, 0, n)
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define rrep(i, a, b) for (auto i = a; i > b; i--)
#define range(i, a, b) (a <... | ### Prompt
Generate a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the s... |
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
... | ### Prompt
Develop a solution in CPP to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main(){
while (1){
int n, m, c, s, g;
cin >> n >> m >> c >> s >> g;
if (n == 0 && m == 0 && c == 0 && s == 0 && g == 0){
break;
}
s--;
g--;
vector<vector<vector<int>>> E(c, vector<vector<int>>(n, vector<int>(n, INF... | ### Prompt
Develop a solution in CPP to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <queue>
#include <cstdio>
#include <vector>
using namespace std;
struct edge { int to, cost; };
bool operator<(const edge& e1, const edge& e2) { return e1.cost < e2.cost; }
int N, M, C, b1, b2, e1, e2, e3, e4;
int main() {
while (scanf("%d%d%d%d%d", &N, &M, &C, &b1, &b2), b1--, b2--, N) {
vector<vector<vect... | ### Prompt
Generate a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the s... |
#include <bits/stdc++.h>
using namespace std;
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
struct edge {int from, to, dist, comp;};
int main()
{
int n, m, c, s, g;
const int INF = 9999999;
while(true){
scanf("%d %d %d %d %d\n",&n, &m, &c, &s, &g);
if(n==0 && m==0 && c==0 && s==0 && g==0){return 0;}
int* final_graph = n... | ### Prompt
Your task is to create a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include "bits/stdc++.h"
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1182&lang=jp
using namespace std;
typedef long long ll;
#define INF 1<<25
#define LINF 1LL<<60
#define MAX_D 20010
int main() {
cin.tie(0); ios::sync_with_stdio(false);
ll n, m, c, s, g;
while (cin >> n >> m >> c >> s >> g, n | m |... | ### Prompt
Your task is to create a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;
#define FOR(i,k,n) for(int i=(k); i<(int)(n);... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int,int> P;
int N,M,C,S,G;
int dp[110] = {};
int g[21][110][110] = {};
int di[21][110][110] = {};
int p[110],q[21][51],r[21][51];
int cost[21][10010] = {};
int inf = 1e9;
vector<vector<P>> v(110);
int calc(int ... | ### Prompt
In CPP, your task is to solve the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with th... |
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>... | ### Prompt
Please create a solution in cpp to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX_N 105
#define MAX_C 25
#define INF (1e8)
vector<int> T[MAX_C],U[MAX_C];
int G[MAX_C][MAX_N][MAX_N];
int n,m,c,s,g;
int d[MAX_N];
void init(){
for(int i=0;i<MAX_C;i++){
T[i].clear();
U[i].clear();
}
for(int i=0;i<MAX_N;i++... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with ... |
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
#include<string>
#include<functional>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int n,m,c,s,g;
int x,y,d,ct;
int p[21],q[21][61],r[21][61];
int fie[101][101][21];
int fie2[101][101];
int... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,m,c,s,g;
while(cin >> n >> m >> c >> s >> g && n) {
s--,g--;
int d2[c][n][n];
for(int i=0; i<c; i++)
for(int j=0; j<n; j++)
for(int k=0; k<n; k++) d2[i][j][k]=(j==k?0:(1<<28));
for(int i=0; i<m; i++) {
int x,y,z... | ### Prompt
Your task is to create a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
... | ### Prompt
Generate a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the s... |
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typ... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with ... |
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define INF 1e9
#define F first
#define S second
typedef pair<int, int> P;
int n, m, c, s, g;
int train[25][105][105];
int p[25], q[25][55], r[25][55];
int fare[105][105];
int flag[105];
void init(){
for(int i = 0; i < 105; i++){
flag[i] = -... | ### Prompt
Construct a CPP code solution to the problem outlined:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with ... |
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>
#include <set>
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long l... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
int dis[20][100][100],p[20],wage[20][10011],dist[100][100];
int inf=1e+8;
int main(){
while(true){
int n,m,c,s,g;
scanf... | ### Prompt
Generate a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the s... |
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstdio>
#include<cstring>
using namespace std;
#define REP(i,x,n) for(int i = x ; i < (int)(n) ; i++)
#define rep(i,n) REP(i,0,n)
static const int INF = (1 << 29);
int n,m,c,s,g;
int p[55],q[55],r[55];
int tmpCost[20010][2... | ### Prompt
Create a solution in Cpp for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
using namespace std;
const int INF = (1<<30) - 1;
int main(){
ios::sync_with_stdio(false)... | ### Prompt
Create a solution in Cpp for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;
struct edge { int from, to, cap, cost, rev; };
int N, M, C, S, T;
const int INF = 1 << 28;
int main() {
while (cin >> N >> M >> C >> S >> T, N + M + C + S + T) {
S--, T--;
vector<mat> ccost(C, mat(N... | ### Prompt
Please formulate a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
static const int INF = 1e9;
void warshall_floyd(vector<vector<int>>& dist)
{
const int n = dist.size();
for (int k = 0; k < n; ++k)
for (int i = 0; i < n; ++i)
... | ### Prompt
Create a solution in CPP for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
/*
* Problem link
*
*/
#include<bits/stdc++.h>
using namespace std;
struct INIT{INIT(){cin.tie(0);ios_base::sync_with_stdio(false);} }init;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
typedef long long LL;
const LL INF = (LL)1e9;
typedef vector<LL> V;
typedef vector<V> VV;
inline LL calc(LL d, V& dist, V& cost) {
LL... | ### Prompt
Construct a CPP code solution to the problem outlined:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with ... |
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> vi;
typedef vector<vi> vvi;
typed... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF (1<<28)
#define REP(i,n) for(int i=0;i<n;i++)
int a[110][110],wf[30][110][110],p[30],q[100],r[100],sum[100];
int n,m,c,s,g,x,y,d,id,tmp;
int main(){
while(scanf("%d%d%d%d%d",&n,&m,&c,&s,&g),n){
REP(i,n)REP(j,n){
a[i][j] = INF;
RE... | ### Prompt
Create a solution in cpp for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
typedef long long LL;
typedef long double LD;
struct edge{
int to;
int dist;
int cmp;
};
struct sta{
int id;
int dist;
};
i... | ### Prompt
Generate a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the s... |
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> II;
int G[20][100][100];
int F[100][100];
int memo[100];
int P[20];
int Q[20][51],R[20][51];
bool visited[100];
int fee(int c, int dist){
int ret=0;
for(int i=1;i<=P[c];i++){
if(dist... | ### Prompt
Please create a solution in cpp to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include<bits/stdc++.h>
#define reps(i,j,k) for(int i=(j); i<(k); i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define fr fs
#define sc second
#define pb push_back
#define mk make_pair
#define INF 1e9
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
int D[20][128][12... | ### Prompt
Create a solution in Cpp for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
struct NODE{
int to,cost,x;
NODE(int to,int cost,int x) : to(to) , cost(cost) , x(x) {}
};
bool operator < (const NODE &a,const NODE &b){
return a.cost > b.cost;
}
int q[20][100];
int r[20][100];
int num[20];
int dis... | ### Prompt
Your task is to create a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include<iostream>
#include<vector>
#include<algorithm>
const int INF=1000000000;
using namespace std;
int main(void){
int n,m,c,s,g,x,y,d,C;
int p[21],q[21][51],r[21][51];
int graph[21][101][101],G[101][101],cost[21][20001];;
while(cin >> n >> m >> c >> s >> g,n|m|c|s|g){
fill(graph[0... | ### Prompt
Construct a cpp code solution to the problem outlined:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with ... |
#include <bits/stdc++.h>
#define var auto
#define ll long long
//#define APPLY(a, f) f(a.begin(), a.end())
#define APPLY(a, f, ...) f(a.begin(), a.end(), __VA_ARGS__)
#define FUN1(x, f) [&](auto& x){return f;}
#define FUN2(x, y, f) [&](auto& x){return f;}
using namespace std;
int main() {
while (true){
i... | ### Prompt
Please formulate a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
while (1) {
int n, m, c, s, t;
cin >> n >> m >> c >> s >> t;
if (n == 0) break;
vector<vector<vector<int>>> dist(c, vector<vector<int>>(n, vector<int>(n, 1e9)));
for ... | ### Prompt
In cpp, your task is to solve the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with th... |
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
using namespace std;
inline int toInt(string s) ... | ### Prompt
Develop a solution in CPP to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include "bits/stdc++.h"
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF (1LL<<59)
ll d[20][100][100];
vector<int> q[20];
vector<int> r[20];
... | ### Prompt
Please formulate a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int n,m,c,s,g;
LL dp[25][101][101];
LL d[101][101];
LL x[100001];
LL y[10... | ### Prompt
In Cpp, your task is to solve the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with th... |
#include<bits/stdc++.h>
#define inf (1e8)
using namespace std;
int n,m,c,s,g;
int dis[21][101][101];
int cost[21][20001];
class State{
public:
int v,cost;
State(int v,int cost):v(v),cost(cost){}
bool operator<(State s)const{
return s.cost<cost;
}
};
void init(){
for(int i=0;i<c;i++){
for(int j=0;j<... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define mp(a, b) make_pair(a, b)
const int inf = 1 << 28;
template<typename T> void chmin(T &t, T f){if(t > f)t = f;}
int n, m, c, s, g;
vector<vector<vector<int> > > dist, cost;
vector<int> mem;
... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
class Edge
{
public:
int src,dst,cst;
Edge(int src, int dst, int cst)
:src(src),dst(dst),cst(cst)
{}
};
class State
{
public:
int p,c,d;
State(int p, int c, int d)
:p(p),c(c),d(d)
{}
bool ope... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
using namespace std;
#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--)
#def... | ### Prompt
Generate a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the s... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;
const int INF = 1<<29;
int N, M, C, S, G;
int p[22];
int q[22][52], r[22][52];
int cost[22][200 * 100 + 2];
int mat[22][102][102];
int main(){
while(true){
cin >> N >> M >> C >> S >>... | ### Prompt
Construct a cpp code solution to the problem outlined:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with ... |
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
using namespace std;
#define ... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace ... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int fare[101][101], dist[21][101][101];
int P[21];
int N, M, C, S, G;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
w... | ### Prompt
Create a solution in CPP for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#defi... | ### Prompt
Your task is to create a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define all(v) v.begin(),v.end()
template<class T> bool set_min(T &a, const T &b) { return a > b ? a = b, true : false; }
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return ... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,C,S,T,p[21],q[21][51],r[21][51];
int G[20][101][101];
void init(){
for(int i=0;i<20;i++)
for(int j=0;j<100;j++)
for(int k=0;k<100;k++)G[i][j][k]=1e9;
}
int calc(int c,int D){
int res=0;
for(int i=1;i<p[c]&&D;i++){
int d... | ### Prompt
Please create a solution in CPP to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef l... | ### Prompt
Create a solution in cpp for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const int INF = 1000000000;
int main() {
int d[20][100][100] = {};
int N, M, C, S, G;
while(cin >> N >> M >> C >> S >> G && N > 0) {
S--; G--;
REP(i, 20) REP(j, 100) REP(k, 100) d[i][j][k] = (j ... | ### Prompt
In CPP, your task is to solve the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with th... |
#include<cstdio>
#include<algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int a[100][100],wf[20][100][100],p[20],q[50],r[51],sum[51];
int n,m,c,s,g,x,y,d,id,tmp;
const int INF = (1<<28);
int main(){
while(scanf("%d%d%d%d%d",&n,&m,&c,&s,&g),n){
REP(i,n)REP(j,n){
a[i][j] = INF;
... | ### Prompt
Please formulate a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <bits/stdc++.h>
using namespace std;
class Edge{
public:
int to,d,c;
};
int N,M,C,s,g;
vector<vector<Edge>> es;
vector<vector<int>> Q,R;
vector<int> p;
vector<vector<int>> fare;
long long distances[101][101];
int getFare(int d, int c){
const vector<int>& q = Q[c];
const vector<int>& r = R[c];
if(r.... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF (1LL<<50)
#define REP(i,n) for(int i=0;i<(int)n;i++)
typedef long long int ll;
typedef pair<ll,int> P;
ll wf[30][110][110],a[110][110],q[30][100],r[30][100],d;
int n,m,c,s,g,x,y,id,p[30];
int main(){
while(scanf("%d%d%d%d%d",&n,&m,&c,&s,&g), n){... | ### Prompt
Develop a solution in cpp to the problem described below:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,C,S,T,p[21],q[21][51],r[21][51];
int G[20][101][101];
int calc(int c,int D){
int res=0;
for(int i=1;i<p[c]&&D;i++){
int d=min(D,q[c][i]-q[c][i-1]);
D-=d;
res+=d*r[c][i-1];
}
if(D) res+=D*r[c][p[c]-1];
return res;
}
in... | ### Prompt
Your task is to create a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <utility>
#include <climits>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long int llg;
const int INF = 1000001000;
#define REP(var, count) for(int var=0; var<count; var++)
template<typena... | ### Prompt
Please create a solution in Cpp to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#inclu... | ### Prompt
Construct a CPP code solution to the problem outlined:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with ... |
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <cstdio>
#define FOR(i,... | ### Prompt
Create a solution in Cpp for the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the... |
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
#define F first
#define Se second
#define INF (1<<29)
int N,M,C,S,g;
int p[51];
int Q[51][20001];
int q[51];
int R[51][20001];
s... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[101][101][21];
int cost[21][200003];
int cost2[101][101];
int n,m,c,s,g,p[55],q[55],r[55];
void init(){
r(i,101)r(j,101)r(k,21)dp[i][j][k]=(i==j?0:1e8);
r(i,101)r(j,101)cost2[i][j]=(i==j?0:1e8);
memset(cost,0,sizeof(cost));
}
... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
//37
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (1<<29)
int main(){
for(int n,m,c,s,g;cin>>n>>m>>c>>s>>g,n|m|c|s|g;){
int dc[21][101][101];
fill(dc[0][0],dc[21][0],INF);
while(m--){
int x,y,d,c;
cin>>x>>y>>d>>c;
dc[c][x][y]=dc[c][y][x]=min(dc[c][x][y],d);
... | ### Prompt
Your task is to create a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
#define MAX 110
#define N 30
#define INF 0x3fffffff
int n, m, cn, start, dest, ans;
int len[N][MAX], fax[N][MAX], faxn[N];
int distc[MAX][MAX][N], dist[MAX][MAX];
inline int find_cost(int val, int c){
if(val == INF) retur... | ### Prompt
Generate a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the s... |
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf = 1e9;
typedef pair<mp,ll> mmp;
typedef pair<mp,mp> mpp;
typedef pair<mpp,ll> mpm;
int main(){
while(1){
ll n,m,c,s,gg;
cin>>n>>m>>c>>s>>gg;
if(n==0)break;
s--,gg--;
vector<vector<mmp> > g(n);
for(int i=0;i<m... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,... | ### Prompt
Please formulate a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define FORR(i,a,b) for(int i=(int)b-1; i>=a; i--)
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
#define DEBUG(x) ... | ### Prompt
Construct a cpp code solution to the problem outlined:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with ... |
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#include<set>
using namespace std;
int road[20][100][100];
int cost[20][20001];
int mincost[100][100];
int movecost[100];
bool movee[100];
int INF = 1 << 28;
#define lengthof(x) (sizeof(x) /... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with ... |
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,c,s,g,e[21][101][101],un[21][20001];
int solve(){
int used[101]={};
priority_queue<P,vector<P>,greater<P> > Q;
Q.push(P(0,s));
while(!Q.empty()){
int ct=Q.top().first,pos=Q.top().second;Q.pop();
if(used[pos]++)continue;
i... | ### Prompt
In Cpp, your task is to solve the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with th... |
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<complex>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
const int R = 22;
const int N = 101;
const int INF = 1000000000;
cons... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int fare[101][101], dist[21][101][101];
int cost[101];
int P[21];
int N, M, C, S, G;
typedef pair<int, int> pint;
int main(){
cin.ti... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, t... |
#include<bits/stdc++.h>
#define INF (1e9)
#define M 10005
#define N 105
#define L 55
#define C 20
using namespace std;
typedef pair<int,int> P;
int n,m,c,s,g,x,y,id,ic,p[C],q[L],r[L];
int cost1[C][N][N];
int cost2[C][M];
int d[N];
int tocost(int a,int b){
if(b<M)return cost2[a][b];
return cost2[a][M-1]+(b-M+1)*(c... | ### Prompt
Generate a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path with the s... |
#include <iostream>
#include <vector>
using namespace std;
#define M_MAX 1000000000000000LL
int main() {
while( true ) {
long long int n, m, c, s, g;
cin >> n >> m >> c >> s >> g;
if ( n == 0 ) break;
long long int d[101][101][21] = {};
for ( long long int i = 0; i <= n; i++ ) {
for ( ... | ### Prompt
Please formulate a Cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
int N, M, C, s, g;
long long int INF = 1e15;
while(cin >> N >> M >> C >> s >> g, N){
--s;--g;
vector< vector<long long int> > G(N, vector<long long int>(N,INF));
vector< vector< vector<long long int> > > D(C, ... | ### Prompt
Your task is to create a cpp solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the p... |
#include <iostream>
#include <vector>
using namespace std;
const int MN = 110;
const int INF = 1<<29;
int sd[22][MN][MN];
int dist[MN][MN];
bool solve() {
int n, m, C, s, g;
cin >> n >> m >> C >> s >> g; s--; g--;
if (!n) return false;
for (int c = 0; c < C; c++) {
for (int i = 0; i < n; i++) {
for (int j = ... | ### Prompt
Please formulate a CPP solution to the following problem:
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.
<image>
Figure D-1: A sample railway network
Suppose you are going to station D from station A. Obviously, the path wi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.