Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct lstInt{
- lstInt *r;
- lstInt *last;
- int val;
- lstInt() {
- r = nullptr;
- last = nullptr;
- val = 0;
- }
- };
- void pbInt(lstInt *root, int num) {
- if (!root->last) {
- root->r = new lstInt;
- root->last = root->r;
- root->last->val = num;
- return;
- }
- lstInt *v = root->last;
- v->r = new lstInt;
- v = v->r;
- v->val = num;
- root->last = v;
- }
- struct lstString{
- lstString *r;
- lstString *last;
- string val;
- lstString() {
- r = nullptr;
- last = nullptr;
- val = "";
- }
- };
- void pbString(lstString *root, string num) {
- if (!root->last) {
- root->r = new lstString;
- root->last = root->r;
- root->last->val = num;
- return;
- }
- lstString *v = root->last;
- v->r = new lstString;
- v = v->r;
- v->val = num;
- root->last = v;
- }
- int main(){
- lstInt *rootInt = new lstInt;
- lstString *rootString = new lstString;
- int n;
- cin>>n;
- for (int i = 0 ; i < n ; ++ i) {
- string x;
- cin>>x;
- pbString(rootString, x);
- }
- for (int i = 0 ; i < n ; ++ i) {
- int x;
- cin>>x;
- pbInt(rootInt, x);
- }
- lstString *vS = rootString -> r;
- lstInt *vI = rootInt -> r;
- while (1) {
- cout<< vS->val << " got " << vI->val << "'s ticket"<<endl;
- if (vS->r == nullptr || vI->r == nullptr) break;
- else {
- vS = vS->r;
- vI = vI->r;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement