output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include<iostream> using namespace std; int main(){ int n,m; while(cin>>n){ if(n==0) break; char c[n][2],s; for(int i=0;i<n;i++) cin >> c[i][0] >> c[i][1]; cin >> m; for(int i=0;i<m;i++){ cin >> s; for(int j=0;j<n;j++){ if(s==c[j][0]){ s = c[j][1]; break; } } cout...
### Prompt Generate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. ...
#include<iostream> using namespace std; int main(){ char ch[8000]; int n,m; char l,r; while(1){ cin>>n; if(n==0) break; for(int i=0;i<3000;i++){ ch[i]='@'; } for(int i=0;i<n;i++){ cin>>l>>r; ch[l]=r; } cin>>m; for(int i=0;i<m;i++){ cin>>l; if(ch[l]=='@') cout<<l; else co...
### Prompt Your task is to create a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conv...
#include <stdio.h> int main(void) { unsigned char table[256]; char c[2]; int n, m; while (1){ for (int i = 0; i < 256; i++){ table[i] = i; } scanf("%d", &n); if (n == 0){ break; } for (int i = 0; i < n; i++){ char c1[2], c2[2]; scanf("%s%s", c1, c2); table[c1[0]] = c2[0]; } ...
### Prompt Please provide a CPP coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include<iostream> #include<map> using namespace std; int main(){ map<char,char> table; int n; char s,t; while(cin>>n&&n){ table.clear(); while(n--){ cin>>s>>t; table[s] = t; } cin>>n; while(n--){ cin>>s; if(table.find(s)!=table.end())cout<<table[s]; else cout<<s; } cout<<endl; } ret...
### Prompt Develop a solution in Cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include <iostream> #include <map> using namespace std; int main(void){ int n; char c1,c2; map <char,char> m; while( cin >> n , n ){ m.clear(); for( int i = 0 ; i < n ; i++ ){ cin >> c1 >> c2; m[c1] = c2; } cin >> n; while(n--){ cin >> c1; if( m[c1] ) ...
### Prompt Develop a solution in cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include <iostream> #include <map> #include <string> #include <algorithm> using namespace std; int main(){ int n,m; while( cin >> n , n ){ map<char,char> f; for(int i=0 ; i<n ; ++i ){ char c , c_; cin >> c >> c_ ; f[c] = c_; } cin >> m; string s; for(int i=0 ; i<m ; ++i ){ char c; cin >> c...
### Prompt Generate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. ...
#include <iostream> using namespace std; int main(void){ char a[100000],b[100000],c; int m,n,f; while(1){ cin>>n; if(!n) break; for(int i=0;i<n;i++) cin>>a[i]>>b[i]; cin>>m; for(int j=0;j<m;j++){ f=1; cin>>c; for(int k=0;k<n;k++){ if(c==a[k]){ f=0; cout<<b[...
### Prompt Generate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. ...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <map> using namespace std; int main(){ int n; while (cin >> n, n){ map<char, char> mp; while (n--){ char c, d; cin >> c >> d; mp[c] = d; } int m; cin >> m; while (m--){ char c; cin >> c; if (mp.count...
### Prompt Create a solution in Cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table...
#include<iostream> using namespace std; int main(){ int n,m; while(cin>>n,n){ char a,b,l[62] = {0}; while(n--) cin >> a >> b,l[a > 96?a - 97:a > 64?a - 39:a > 47?a + 4:0] = b; cin >> m; string s = ""; while(m--){ cin >> a;b = l[a > 96?a - 97:a > 64?a - 39:a > 47?a + 4:0];if(b==0)b = a;s+=b;} cout <<...
### Prompt Develop a solution in Cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include <iostream> using namespace std; int main(){long n;while(cin>>n,n){char d,s,m[256]={0};for(;n--;m[(int)s]=d)cin>>s>>d;for(cin>>n;n--;cout<<(m[(int)s]?m[(int)s]:s))cin>>s;cout<<endl;}}
### Prompt Your task is to create a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conv...
#include<iostream> using namespace std; int main(){ char a[100000][2]; int n,m; char in; while(cin>>n,n){ for(int i=0;i<n;i++){ cin>>a[i][0]>>a[i][1]; } cin>>m; for(int i=0;i<m;i++){ cin>>in; bool flg=true; for(int j=0;j<n;j++){ if(a[j][0]==in){cout<<a[j][1];flg=false;br...
### Prompt In CPP, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion tabl...
#include<iostream> #include<map> using namespace std; int main() { int n,m; char c1,c2; map<char,char>convert; while(cin>>n,n){ convert.clear(); while(n-->0){ cin>>c1>>c2; convert[c1]=c2; } cin>>m; while(m-->0){ cin>>c1; if(convert.find(c1)!=convert.end())printf("%c",...
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table...
#include<iostream> #include<string> using namespace std; int main(){ int n,m; char a[100],b[100],c[100001]; while(true){ cin>>n; if(n==0) break; for(int i=0;i<n;i++) cin>>a[i]>>b[i]; cin>>m; for(int i=0;i<m;i++){ cin>>c[i]; int j=0; while(true){ if(a[j]==c[i]){ c[i]=b[j]; break; } j++...
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table...
#include <iostream> #include <vector> using namespace std; int main(void){ while (1) { int n; cin >> n; if (!n) break; vector<char> v1, v2; for (int i = 0; i < n; i++) { char c; cin >> c; v1.push_back(c); cin >> c; v2.push_back(c); } int m; cin >> m; for (int i = 0; i < m; i++) { char b; ...
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table...
#include <iostream> #include <string> using namespace std; int main(){ int n; int c; string d; int m; int e; int f; while(cin >> n){ if(n!=0){ string a[n]; string b[n]; c=0; while(c<n){ cin >>a[c]; cin >>b[c]; c=c+1;} cin >> m; c=0; while(c<m){ cin >>d; e=0; f=0; while(e<n){ if(d==a[e]){cout<<b[e]; f=1;} e=e+1; } ...
### Prompt Develop a solution in Cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include<iostream> using namespace std; int main(){ int n,m; while(1){ cin>>n; char a[n],b[n],cha; if(n==0) break; for(int i=0;i<n;i++){ cin>>a[i]>>b[i]; } cin>>m; for(int i=0;i<m;i++){ cin>>cha; for(int j=0;j<n;j++){ if(cha==a[j]){ cout<<b[j]; break; ...
### Prompt Construct a CPP code solution to the problem outlined: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion ta...
#include <cstdio> #include <cstring> char c[128]; int main(void) { while(1){ int n; scanf("%d",&n); if(!n) break; memset(c,0,sizeof(c)); for(int i=0;i<n;i++){ char a,b; scanf(" %c %c",&a,&b); c[a] = b; } int m; scanf("%d",&m); for(int i=0;i<m;i++){ char a; ...
### Prompt Please create a solution in cpp to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include <stdio.h> int main() { char trans[256]; char c, c2, str[10]; long n, m, i; while (scanf("%ld", &n), n) { for (i = 0; i < 256; ++i) trans[i] = i; for (i = 0; i < n; ++i) { scanf("%s", str); c = str[0]; scanf("%s", str); c2 = str[0]; trans[c] = c2; } scanf("%ld", &m); for (i = 0; i...
### Prompt Your challenge is to write a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include <iostream> using namespace std; int main() { int n; while(cin >> n, n){ char a,b; char d[1000]; for(int i = 0; i < 1000; i++) d[i] = -1; while(n > 0){ n--; cin >> a >> b; d[a] = b; } cin >> n; char *s = new char[n+1]; for(int i = 0; i < n; i++){ cin >> a; if(d[a] !...
### Prompt Generate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. ...
#include<iostream> #include<map> using namespace std; int main(void){ int n,m; while(cin >> n, n != 0){ char c, d; map<char, char> tb; for(int i = 0; i < n; i++){ cin >> c >> d; tb[c] = d; } cin >> m; for(int i = 0; i < m; i++){ cin >> c; if(tb.find(c) != tb.end()) cout << tb[c]; else ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include <iostream> #include <string> using namespace std; int main() { while(1){ int a; cin >> a; if(a == 0){break;} char *b = new char [a]; char *c = new char [a]; for(int i = 0;i < a;i++){ cin >> b[i] >> c[i]; } int m; cin >> m; for(int i = 1;i <= m;i++){ char p; cin >> p; int ii = 0; while(ii < a){ if(p == b[ii])...
### Prompt Please provide a CPP coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include<iostream> using namespace std; char map[256]; int main(){ while(true){ for(int i = 0;i < 256;i++){ map[i] = i; } int n; cin >> n; if(n==0)break; for(int i = 0; i < n;i ++){ char c,d; cin >> c >> d; map[c] = d; } cin >> n; for(int i = 0;i ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include <cstdio> int main(){ int n, m; static int dict[256]; char k, v, x; while (scanf("%d\n", &n)){ if (!n) return 0; for (int i = 0; i<256; i++) dict[i] = i; for (int i = 0; i<n; i++){ scanf("%c %c\n", &k, &v); dict[(int)k] = (int)v; } scanf("%d\n", &m); for (int i = 0; i<m; i++){ scanf("%...
### Prompt Please formulate a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include <iostream> #include <map> using namespace std; int main ( void ) { int n; while ( cin >> n, n ) { map<char, char> t; for (int i = 0; i < n; ++i) { char a, b; cin >> a >> b; t[a] = b; } int m; cin >> m; for (int i = 0; i < m; ++i) { char c; cin >> c; if ( t.count(c) ) ...
### Prompt Please create a solution in Cpp to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include<bits/stdc++.h> using namespace std; int main() { int n; while( cin >> n, n ) { map<char,char> data; for(int i=0; i<n; i++) { char c1, c2; cin >> c1 >> c2; data[c1] = c2; } int m; char c; string s = ""; cin >> m; for(int i=0; i<m; i++) { cin >> c; ...
### Prompt Construct a Cpp code solution to the problem outlined: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion ta...
#include<iostream> class table{ char tab[128]; public: table(){for(unsigned char i=0;i<128;++i)tab[i]=i;} char& operator[](char p){return tab[p];} const char& operator[](char p)const{return tab[p];} }; int main(){ int n; while(1){ std::cin>>n; if(!n)return 0; table tab; while(n--){char a,b;std::cin>>...
### Prompt Your task is to create a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conv...
#include <stdio.h> int main(void) { int n,m; char trans[100][2]; char c; while (scanf("%d", &n), n) { for (int i = 0; i < n; i++) { scanf(" %c %c", &trans[i][0], &trans[i][1]); } scanf("%d", &m); for (int i = 0; i < m; i++) { scanf(" %c", &c); for (int j = 0; j < n; j++) { if (trans[j][0] == ...
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table...
#include <iostream> using namespace std; int main(){ int n,m,i=0,j=0,k=0; char rule[50][2],data[100000]; while(j<5){ cin>>n; if(n==0){break;} for(i=0;i<n;i++){ cin>>rule[i][0]; cin>>rule[i][1]; } cin>>m; for(i=0;i<m;i++){ cin>>data[i]; for(k=0;k<n;k++){ if(data[i]==rule[k][0]){ ...
### Prompt In Cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion tabl...
#include <iostream> #include <map> #include <string> using namespace std; int main(){ int n; char a,b; map<char,char> m; string s; while(cin>>n,n){ m.clear(); while(n--){ cin>>a>>b; m[a]=b; } cin>>n; s=""; while(n--){ cin>>a; if(m.find(a)==m.end()) s+=a; ...
### Prompt Construct a cpp code solution to the problem outlined: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion ta...
#include <iostream> #include <vector> using namespace std; int main(){ while(1){ int n; cin >> n; if(n==0) break; vector<char> conv(128); for(int i=0; i<128; i++) conv[i]=i; for(int i=0; i<n; i++){ char a,b; cin >> a >> b; conv[a] = b; } int m; cin >> m; for(int i=0; i<m; i++){ c...
### Prompt Develop a solution in cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include <bits/stdc++.h> using namespace std; int main(){ int N,M; char graph[128]; while(cin >> N,N){ for(int i = 0;i < 128;i++)graph[i] = i; char a,b; for(int i = 0;i < N;i++){ cin >> a >> b; graph[a] = b; } cin >> M; for(int i = 0;i < M;i++){ cin >> a; cout << gr...
### Prompt Your challenge is to write a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include <map> #include <iostream> using namespace std; int main() { int N, M; char A, B, C; while (true) { cin >> N; if (N == 0) { break; } map<char, char> converse; for (char i = '0'; i <= 'z'; i++) { converse[i] = i; } for (int i = 0; i < N; i++) { cin >> A >> B; converse[A] = B...
### Prompt Please create a solution in cpp to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include<cstdio> #include<map> using namespace std; int main(){ int n,m; char a,b; while(scanf(" %d ",&n),n){ map<char,char> t; for(int i=0;i<n;i++){ scanf(" %c %c ",&a,&b); t[a] = b; } scanf(" %d ",&m); for(int i=0;i<m;i++){ scanf(" %c ",&a); if(t.find(a)!=t.end())p...
### Prompt Your task is to create a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conv...
#include<stdio.h> int main(void) { int n,m; char a[1000],b[1000],c; int i,j; scanf("%d",&n); while(n!=0){ for(i=0;i<n;i++){ scanf(" %c %c",&a[i],&b[i]); } scanf("%d",&m); for(i=0;i<m;i++){ scanf(" %c",&c); for(j=0;j<n;j++){ if(c==a[j]){ c=b[j]; break; } } printf("%c",...
### Prompt Generate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. ...
#include<iostream> using namespace std; int main(){ int n,r; char a[1000],b[1000],x,y; while(cin>>n,n){ for(int i=0;i<n;i++){ cin>>x>>y; a[i]=x; b[i]=y; } cin>>r; for(int i=0;i<r;i++){ cin>>x; int j; for(j=0;j<n;j++) if(a[j]==x){ cout<<b[j]; break; } if(j==n) cout<<x; ...
### Prompt Please create a solution in CPP to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include <stdio.h> int main(){ int n,i,j,m,f; char a[256],b[256],x; while(1){ scanf("%d ",&n); if(n==0){ break; } for(i=0;i<n;i++){ scanf("%c %c ",&a[i],&b[i]); } scanf("%d ",&m); for(i=0;i<m;i++){ scanf("%s",&x); f=0; for(j=0;j<n;j++){ if(x==a[j]){ printf("%c",b[j]); f=1; brea...
### Prompt Your task is to create a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conv...
#include <bits/stdc++.h> using namespace std; int main(){ int N,M; char graph[128]; while(cin >> N,N){ for(int i = 0;i < 128;i++)graph[i] = i; char a,b; for(int i = 0;i < N;i++){ scanf(" %c %c",&a,&b); graph[a] = b; } cin >> M; for(int i = 0;i < M;i++){ scanf(" %c",&a); ...
### Prompt Please provide a Cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include<iostream> #include<cstdio> using namespace std; int main(){ while(1){ int n; scanf("%d",&n); if(n==0)break; char f[1002]; for(int i=0;i<1002;i++)f[i]=(char)i; for(int i=0;i<n;i++){ char c,d; scanf("\n%c %c",&c,&d); f[(int)c] = d; } int m; scanf("%d",&m); for(int i=0;i<m;i++){ char c; scanf("\n%c",&c); printf(...
### Prompt Please create a solution in Cpp to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include<iostream> #include<string> #include<map> using namespace std; int main(){ int n; while (cin >> n && n != 0){ map<string, string> m; string s1, s2; for (int i = 0; i < n; i++){ cin >> s1 >> s2; m[s1] = s2; } cin >> n; string line; for (int i = 0; i < n; i++){ cin >> s1; if (m.find(s...
### Prompt Generate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. ...
#include <iostream> #include <map> using namespace std; int main() { int n; while (cin >> n, n) { map<char, char> table; for (int i = 0; i < n; i++) { char a, b; cin >> a >> b; table[a] = b; } cin >> n; for (int i = 0; i < n; i++) { char c; cin >> c; if (table.count(c)) cout << table...
### Prompt Create a solution in CPP for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table...
#include "iostream" #include "map" #include "string" using namespace std; int main(void) { int n; while (cin>>n,n) { map<char, char> m; for (int i = 0; i < n; i++) { char l,r; cin>>l>>r; m[l]=r; } string ans=""; int num; cin>>num; while (num--) { char t; cin>>t; if(m.count(t)) ans+=m[t]; el...
### Prompt Please create a solution in Cpp to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include <iostream> using namespace std; int main() { int n, m; while(cin >> n, n) { cin.ignore(); int conv[256] = {}; for(int i = 0; i < n; i++) { char c, d; cin >> c; cin.ignore(); cin >> d; cin.ignore(); conv[c] = d; } cin >> m; cin.ignore(); for(int i = 0; i < m; i++) { char c; cin ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<n;i++) using namespace std; typedef long long ll; int main() { int n; while (cin >> n, n) { map<char, char>mp; rep(i, n) { char c, d; cin >> c >> d; mp[c] = d; } int m; cin >> m; string s = ""; rep(i, m) { char c; cin >> c; if (mp[c] == ...
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table...
#include <iostream> #include <cstdio> using namespace std; int main(){ long long i,j,n,m; cin >> n; while(n){ char c[2][n],p; for(i=0;i<n;i++) cin >> c[0][i] >> c[1][i]; cin >> m; for(i=0;i<m;i++) { cin >> p; for(j=0;j<n;j++) if(p==c[0][j]){p=c[1][j]; break;} cout << p; } cout << endl; cin >>...
### Prompt Please provide a Cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include <stdio.h> int main(){ int n,m; char c[2],a[128]; while(1){ scanf("%d",&n); if(n==0)return 0; for(int i=0;i<128;i++)a[i]=i; for(int i=0;i<n;i++){ scanf("%s %s",&c[0],&c[1]); a[c[0]]=c[1]; } scanf("%d",&m); for(int i=0;i<m;i++){ scanf("%s",&...
### Prompt Your task is to create a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conv...
#include <cstdio> int main() { while(true) { int n, m; char table[256]; for(int i = 0; i < 256; ++i) table[i] = i; scanf("%d", &n); if(n == 0) break; for(int i = 0; i < n; ++i) { char a[16], b[16]; scanf("%s%s", a, b); table[a[0]] = b[0]; } scanf("%d", &m); for(int i ...
### Prompt Please formulate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include <cstdio> #include <iostream> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) int main(){ int n; while(cin >> n ,n){ char table[128]; rep(i,128)table[i] = i; rep(i,n){ char a,b; cin >> a >> b; table[a] = b; } int m; cin >> m; rep(i,m){ char c; cin >> c; putchar(table[c...
### Prompt Create a solution in Cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table...
#include <map> #include <iostream> #include <string> using namespace std; int main() { map<char, char> mp; char a,b,c; string x; int n; cin >> n; do{ mp.clear(); x.clear(); do{ cin >> a >> b; mp[a] = b; } while (--n); cin >> n; do{ cin >> c; if (mp[c] != NULL) { x += mp[c]; } ...
### Prompt Create a solution in Cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table...
#include<iostream> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; char m[99][2],z,y; int main(){ int s,n; while(true){ cin>>s; if(s==0)break; rep(i,s)cin>>m[i][0]>>m[i][1]; cin>>n; rep(i,n){ cin>>z; y=z; rep(j,s)if(m[j][0]==z)y=m[j][1]; cout<<y; } cout<<endl; } return 0; }
### Prompt Please provide a CPP coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include <map> #include <string> #include <stdio.h> #include <iostream> using namespace std; int n, m; int i, j; char a, b, c; char list[1000]; int main() { while (1) { scanf("%d", &n); if (n==0) return 0; for (i=0; i<1000; i++) list[i] = i; for (i=0; i<n; i++) { scanf(" %c %c", &a, &b); list[a] = ...
### Prompt In cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion tabl...
#include <iostream> #include <algorithm> using namespace std; int main(void){ int n; while(cin >> n , n){ char dic[256]; fill(dic , dic + 256 , 0); for(int i = 0; i < n; i++){ char c; cin >> c; cin >> dic[c]; } int m; cin >> m; for(int i = 0; i < m; i++){ char c...
### Prompt Create a solution in CPP for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table...
#include <iostream> using namespace std; #define repi(i,a,b) for(int i=(a);i<(b);i++) #define rep(i,n) for(int i=0;i<(n);i++) int main() { ios::sync_with_stdio(false); int n, m; while(cin>>n,n) { char t[256] = {}; char a, b; rep(i, n) { cin>>a>>b; t[a] = b; } cin>>m; rep(i, m) { cin>>a; ...
### Prompt Generate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. ...
#include<cstdio> #include<iostream> using namespace std; int main(){ while(1){ int n,m; char secret; char A[100]={0},B[100]={0}; cin>>n; if(n==0)return 0; for(int i=0;i<n;i++){ cin>>A[i]>>B[i]; } cin>>m; for(int i=0;i<m;i++){ cin>>secret; int flag=0; for(int j=0;j<n;j++){ if(secret=...
### Prompt Please provide a CPP coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
#include <cstdio> #include <map> using namespace std; int main() { int n; while(scanf("%d\n", &n), n){ map<char, char> m; char a, b; for(int i = 0; i < n; i++){ scanf("%c %c\n", &a, &b); m[a] = b; } scanf("%d\n", &n); for(int i = 0; i < n; i++){ scanf("%c\n", &a); putchar(m[a] ? m[a] : a); }...
### Prompt Please create a solution in Cpp to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include <iostream> #include <map> using namespace std; int main(){ int n; char buf; map<char, char> conv; while(1){ cin >> n; if(n != 0){ conv.clear(); for(int i = 0; i < n; i++){ cin >> buf; cin >> conv[buf]; } cin >> n; for(int i = 0; i < n; i++){ cin >> buf; if(co...
### Prompt Generate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. ...
#include<iostream> using namespace std; int main() { int i,j,k; string s; while(1){ cin>>i; if(i==0)break; string c[i][2]; for(j=0;j<i;j++) { cin>>s,c[j][0]=s; cin>>s,c[j][1]=s; } cin>>k; for(j=0;j<k;j++){ cin>>s; for(int l=0;l<i;l++){ if(s==c[l][0]) { s=c[l...
### Prompt Develop a solution in cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion...
#include<bits/stdc++.h> using namespace std; const double EPS = 1e-8, PI = acos(-1), INF = 1e9; inline bool eq(double a, double b) { return abs(b - a) < EPS; } struct Point { double x, y; Point() {}; Point(double x, double y) : x(x), y(y) {}; Point operator+(const Point &b) const { return Point(x + b.x...
### Prompt Develop a solution in cpp to the problem described below: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include <bits/stdc++.h> using namespace std; #define EPS (1e-5) #define equal(a,b) (fabs(a-b) < EPS) #define lt(a,b) (a-b < -EPS) #define MAX 252 #define INF (1e9) #define PI acos(-1) struct Point{ long double x,y; Point(){} Point(long double x,long double y) : x(x),y(y) {} Point operator + (const...
### Prompt Create a solution in CPP for the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that this ...
#include<iostream> #include<vector> #include<cmath> #include<algorithm> #include<cassert> #include<iomanip> #include<queue> #include<cstdio> #define REP(i,s,n) for(int i=s;i<n;i++) #define rep(i,n) REP(i,0,n) #define inf (1<<29) #define EPS (1e-10) #define COUNTER_CLOCKWISE 1 #define CLOCKWISE -1 #define ONLINE_BACK ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good ne...
#include<bits/stdc++.h> using namespace std; const double EPS = 1e-8, PI = acos(-1), INF = 1e9; inline bool eq(double a, double b) { return abs(b - a) < EPS; } struct Point { double x, y; Point() {}; Point(double x, double y) : x(x), y(y) {}; Point operator+(const Point &b) const { return Point(x + b.x...
### Prompt Construct a Cpp code solution to the problem outlined: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that th...
#include <cstdio> #include <cstdlib> #include <cstring> #include <climits> #include <cassert> #include <iostream> #include <iomanip> #include <sstream> #include <algorithm> #include <numeric> #include <complex> #include <stack> #include <queue> #include <list> #include <set> #include <map> #include <bitset> #include <f...
### Prompt Create a solution in cpp for the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that this ...
#include <bits/stdc++.h> using namespace std; using Real = double; using Point = complex< Real >; const Real EPS = 1e-8, PI = acos(-1); inline bool eq(Real a, Real b) { return fabs(b - a) < EPS; } Point operator*(const Point &p, const Real &d) { return Point(real(p) * d, imag(p) * d); } istream &operator>>(istre...
### Prompt Develop a solution in cpp to the problem described below: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include<bits/stdc++.h> #define f first #define s second #define mp make_pair #define pi M_PI #define inf 1e14 #define eps (1e-8) #define MAX 1000 #define equals(a,b) (fabs((a)-(b))<eps) using namespace std; class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y){} Point operator+(Point p){ retu...
### Prompt Develop a solution in CPP to the problem described below: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include <cstdio> #include <iostream> #include <complex> #include <cmath> #include <vector> #include <utility> #include <algorithm> #include <set> #include <queue> using namespace std; #define EPS 1e-8 typedef double D; typedef complex<D> P; typedef const P &rP; typedef pair<int,int> pii; typedef pair<P,P> seg; typed...
### Prompt In CPP, your task is to solve the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that this...
#include <iostream> #include <cassert> #include <vector> #include <set> #include <queue> #include <algorithm> #include <cstdio> #include <cstring> #include <complex> #include <cmath> using namespace std; typedef long long ll; typedef long double R; typedef complex<R> P; namespace std { bool operator < (P a, P b)...
### Prompt Generate a Cpp solution to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that this ro...
#include <iostream> #include <algorithm> #include <cstdio> #include <cmath> #include <complex> #include <vector> #include <set> #include <queue> using namespace std; typedef complex<double> P; typedef pair<P,P> L; typedef vector<vector<vector<double> > > mat; const int INF = 1 << 29; const double EPS = 1e-7; namespa...
### Prompt Please provide a cpp coded solution to the problem described below: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good ne...
#include <cstdio> #include <cmath> #include <cstring> #include <cstdlib> #include <climits> #include <ctime> #include <queue> #include <stack> #include <algorithm> #include <list> #include <vector> #include <set> #include <map> #include <iostream> #include <deque> #include <complex> #include <string> #include <iomanip>...
### Prompt Develop a solution in Cpp to the problem described below: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include <bits/stdc++.h> using namespace std; #define EPS (1e-6) #define equal(a,b) (fabs(a-b) < EPS) #define lt(a,b) (a-b < -EPS) #define MAX 252 #define INF (1e9) #define PI acos(-1) struct Point{ double x,y; Point(){} Point(double x,double y) : x(x),y(y) {} Point operator + (const Point &p)const...
### Prompt Your challenge is to write a CPP solution to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good ne...
#include <bits/stdc++.h> using namespace std; #define EPS (1e-6) #define equal(a,b) (fabs(a-b) < EPS) #define lt(a,b) (a-b < -EPS) #define MAX 252 #define INF (1e9) #define PI acos(-1) struct Point{ double x,y; Point(){} Point(double x,double y) : x(x),y(y) {} Point operator + (const Point &p)const...
### Prompt Please create a solution in Cpp to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include<complex> #include<vector> #include<set> #include<iostream> #include<stack> #include<cmath> #include<queue> #define FRONT 0x01 #define RIGHT 0x02 #define BACK 0x04 #define LEFT 0x08 #define OVER 0x10 #define CIRCLE_SAME 0x01 #define CIRCLE_CONTAIN 0x02 #define CIRCLE_NO_CROSS 0x04 #define CIRCLE_ONE_CROSS 0x0...
### Prompt Your task is to create a Cpp solution to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news i...
#include<iostream> #include<queue> #include<vector> #include<algorithm> #include<complex> #include<cmath> using namespace std; #define REP(i,N) for(int i=0;i<(int)(N);++i) #define ALL(v) (v).begin(),(v).end() typedef complex<double> P; const double EPS = 1e-10; const double PI = 4.0 * atan2(1, 1); namespace std { ...
### Prompt Create a solution in cpp for the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that this ...
#include <bits/stdc++.h> #define REP(i,n) for(int i=0; i<(int)(n); ++i) using namespace std; typedef long long LL; typedef complex<double> P; const double EPS = 1e-8; // 誤差を加味した符号判定 int sign(double x){ return x > EPS ? 1 : x < -EPS ? -1 : 0; } // 内積・外積 double dot(P a, P b){return real(conj(a) * b);} double cross(P a...
### Prompt Your task is to create a cpp solution to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news i...
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #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 <cfloa...
### Prompt Create a solution in CPP for the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that this ...
#include <bits/stdc++.h> using namespace std; using ll=long long; #define int ll #define rng(i,a,b) for(int i=int(a);i<int(b);i++) #define rep(i,b) rng(i,0,b) #define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--) #define per(i,b) gnr(i,0,b) #define pb push_back #define eb emplace_back #define a first #define b second #defi...
### Prompt Your challenge is to write a cpp solution to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good ne...
#include <algorithm> #include <cmath> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <queue> #include <tuple> #include <vector> using namespace std; constexpr double EPS = 1e-9; struct point { double x, y; explicit point(double x_ = 0.0, double y_ = 0.0):x(x_), y(y_) {} point(...
### Prompt Please formulate a CPP solution to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include <bits/stdc++.h> #define REP(i,n) for(int i=0; i<(int)(n); ++i) using namespace std; typedef long long LL; typedef complex<double> P; const double EPS = 1e-8; // 誤差を加味した符号判定 int sign(double x){ return x > EPS ? 1 : x < -EPS ? -1 : 0; } // 内積・外積 double dot(P a, P b){return real(conj(a) * b);} double cross(P a...
### Prompt Please formulate a CPP solution to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include <bits/stdc++.h> #define REP(i,n) for(int i=0; i<(int)(n); ++i) using namespace std; typedef long long LL; typedef complex<double> P; const double EPS = 1e-8; // 誤差を加味した符号判定 int sign(double x){ return x > EPS ? 1 : x < -EPS ? -1 : 0; } // 内積・外積 double dot(P a, P b){return real(conj(a) * b);} double cross(P a...
### Prompt Develop a solution in CPP to the problem described below: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include "bits/stdc++.h" #include<unordered_map> #include<unordered_set> #pragma warning(disable:4996) using namespace std; using ld = long double; template<class T> using Table = vector<vector<T>>; const ld eps = 1e-9; /* ??????????????¬ */ #include <complex> typedef complex<ld> Point; #define rep(i,n) for(int i=0;...
### Prompt Please formulate a cpp solution to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include <bits/stdc++.h> #define REP(i,n) for(int i=0; i<(int)(n); ++i) using namespace std; typedef long long LL; typedef complex<double> P; const double EPS = 1e-8; // 誤差を加味した符号判定 int sign(double x){ return x > EPS ? 1 : x < -EPS ? -1 : 0; } // 内積・外積 double dot(P a, P b){return real(conj(a) * b);} double cross(P a...
### Prompt Please create a solution in CPP to the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include <bits/stdc++.h> using namespace std; #define int long long #define FR first #define SC second #define all(v) (v).begin(), (v).end() #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++) #define each(a, b) for(auto& a : b) typedef pair<int, int> P;...
### Prompt Construct a Cpp code solution to the problem outlined: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that th...
#include<bits/stdc++.h> #define f first #define s second #define mp make_pair #define pi M_PI #define inf 1e14 #define eps (1e-8) #define MAX 1000 #define equals(a,b) (fabs((a)-(b))<eps) using namespace std; class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y){} Point operator+(Point p){ re...
### Prompt Develop a solution in cpp to the problem described below: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
#include <iostream> #include <algorithm> #include <cstdio> #include <cmath> #include <complex> #include <vector> #include <set> #include <queue> using namespace std; typedef complex<double> P; typedef pair<P,P> L; typedef vector<vector<vector<double> > > mat; const int INF = 1 << 29; const double EPS = 1e-7; namespa...
### Prompt Develop a solution in CPP to the problem described below: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that...
//Name: Kuru-Kuru Robot //Level: 3 //Category: 幾何,Geometry,グラフ,Graph,線分アレンジメント,角度,練習問題 //Note: /** * 線分アレンジメントを行ってグラフを作る。 * 回転のコストを求めるためには、最後にたどった線分の角度を覚えておき、次にたどりたい線分の角度との差分を計算すればよい。 * これは、グラフを拡張して、(頂点,直前にいた頂点)を新しい頂点としたグラフにすれば実現できる。 * このグラフの上で、最短経路問題を解けば良い。 * * 線分アレンジメントでは、最大で N(N-1) = O(N^2) 個の頂点が生成され得る。 * した...
### Prompt In CPP, your task is to solve the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that this...
#include <bits/stdc++.h> using namespace std; using Real = double; using Point = complex< Real >; const Real EPS = 1e-8, PI = acos(-1); inline bool eq(Real a, Real b) { return fabs(b - a) < EPS; } Point operator*(const Point &p, const Real &d) { return Point(real(p) * d, imag(p) * d); } istream &operator>>(istre...
### Prompt Create a solution in cpp for the following problem: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that this ...
#include <iostream> #include <iomanip> #include <complex> #include <vector> #include <algorithm> #include <cmath> #include <array> #include <map> #include <queue> using namespace std; const double EPS = 1e-10; const double INF = 1e12; const double PI = acos(-1); #define EQ(n,m) (abs((n)-(m)) < EPS) #define X real() #de...
### Prompt Construct a cpp code solution to the problem outlined: Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that th...
#include <vector> #include <map> #include <set> #include <stack> #include <queue> #include <algorithm> #include <utility> #include <functional> #include <sstream> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> #include <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 <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 <stdio.h> #include <string.h> #include <algorithm> #include <iostream> #include <math.h> #include <assert.h> #include <vector> #include <queue> #include <string> #include <map> #include <set> using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; static const dou...
### 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 <algorithm> #include <vector> #include <queue> 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 operator<(const State&...
### 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 <string> #include <vector> #include <algorithm> #include <utility> #include <cstring> #include <cmath> #include <queue> #include <map> #include <set> using namespace std; #define rep(i,n) for(int i=0; i<n; i++) #define FOR(i,s,n) for(int i=s; i<n; i++) #define ALL(x) x.begin(), x.end() typ...
### 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; #define for_(i,a,b) for(int i=(a);i<(b);++i) #define minit(a, b) memset(a, b, sizeof(a)) #define size_of(a) (int)(a).size() typedef long long lint; struct Edge { int to; lint dst; Edge (int to_, lint dst_) : to(to_), dst(dst_) {} bool operator > (const Edge& e) const ...
### 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...
/* 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 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<algorithm> #include<queue> const int INF=1000000000; using namespace std; struct edge{int to,cost;}; typedef pair<int,int>P; int V,d[101]; vector<edge>G[101]; void dijkstra(int s){ priority_queue<P,vector<P>,greater<P> >que; fill(d,d+V,INF); d[s]=0; que.pus...
### 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> class Solve { private: using vi = std::vector<int64_t>; using vvi = std::vector<vi>; using vvvi = std::vector<vvi>; using i3 = std::array<int64_t, 3>; using vi3 = std::vector<i3>; using vvi3 = std::vector<vi3>; public: bool is_last_query{}; Solve() { int n, m, company, start, goal...
### 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 <vector> using namespace std; int main(){ const long long INF = 1e9; int N, M, C, S, G; while(cin >> N >> M >> C >> S >> G, N){ --S,--G; vector<vector<vector<long long>>> D(C,vector<vector<long long>>(N,vector<long long>(N,INF))); for(int i = 0; i < M; ++i){ int x, ...
### 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; 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 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; const int INF = 1 << 28; int dist[20][100][100]; int d[100][100]; int p[20], q[20][50], r[20][50]; int main() { int n, m, c, s, g; while (cin >> n >> m >> c >> s >> g, n) { s--; g--; fill((int*)dist, (int*)(dist + 20), INF); for (int i = 0; i < c; i++) for (int j = ...
### 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 <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <cstring> #include <climits> #include <cmath> #include <map> #include <queue> #include <sstream> #include <string> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int...
### 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 <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <utility> # include <stack> # include <queue> # include <list> # include <tuple> # include <unordered_map> # include <numeric> # include...
### 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 <iostream> #include <vector> #include <queue> #include <algorithm> using namespace std; #define rep(i, n) for(int i=0; i<(n); ++i) #define all(c) (c).begin(), (c).end() 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...
### 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...