Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Following order Indegree
#include<bits/stdc++.h> using namespace std; #define ll long long int const int N=1e6; vector<int> v[23]; int a[23]; vector<string> ans[23]; vector<int> inc(23); int in[23]; int m[23]; int main() { char c; int n=0; while while(1) { cin>>c; if(c=='/n') break; else m[c-'a']=n,a[n++]=c-'a'; } char c1,c2; while(1) { cin>>c1>>c2; if(c1=='/n') break; else v[m[c1-'a']].push_back(m[c2-'a']),in[m[c2-'a']]++; } for(int i=0;i<n;i++) { inc[in[i]].push_back(i); } for(auto it : inc[0]) { ans[it].push_back((string)(a[it]+'a')); } while(1) { if(inc[0].size()==0) { break; } for(auto it : inc[0]) { for(auto des : v[it]) { for(auto out : ans[it]) { ans[des].push_back(out+(string)(a[des]+'a'+"")); } inc(in[des]).erase(des); inc(in[des]-1).push_back(des); } inc[0].erase(it); } } }
run
|
edit
|
history
|
help
0
Zahra_matrix
Lotto random number game {modify}
cast operator
Travel Buddy
Display all prime numbers upto N without sieve
Vector+-OpLoad
co_assign_1_ques_1
HashTable
ww999
C++ lesson