Advertisement
ambition-xx

c

Aug 4th, 2022
776
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long LL;
  6. const int maxn = 1e4 + 1;
  7. vector<int> S(maxn, 0), No(maxn, 0), U(maxn, 0);
  8. map<string, string> S2No, No2S;
  9.  
  10. int main() {
  11.     string a, op, b;
  12.     while(cin >> a && a != "-1"){
  13.         cin >> op >> b;
  14.         if(a[0] == 'S') {
  15.             if(op == "bind"){
  16.                 if(!S2No.count(a) && !No2S.count(b)){
  17.                     printf("%s bind success\n", a.c_str());
  18.                     S2No[a] = b;
  19.                     No2S[b] = a;
  20.                     continue;
  21.                 } else {
  22.                     printf("%s bind fail\n", a.c_str());
  23.                     continue;
  24.                 }
  25.             } else if (op == "unbind"){
  26.                 if(S2No.count(a) && S2No[a] == b && No2S.count(b) && No2S[b] == a){
  27.                     printf("%s unbind success\n", a.c_str());
  28.                     S2No.erase(a);
  29.                     No2S.erase(b);
  30.                     continue;
  31.                 } else {
  32.                     printf("%s unbind fail\n", a.c_str());
  33.                     continue;
  34.                 }
  35.             } else {
  36.                 printf("unknow command\n");
  37.                 continue;
  38.             }
  39.         } else if (a[0] == 'U') {
  40.             if(op == "scan"){
  41.                 if(No2S.count(b)){
  42.                     printf("%s pay to %s\n", a.c_str(), No2S[b].c_str());
  43.                     continue;
  44.                 } else {
  45.                     printf("%s scan fail\n", a.c_str());
  46.                     continue;
  47.                 }
  48.             } else {
  49.                 printf("unknow command\n");
  50.                 continue;
  51.             }
  52.         }
  53.     }
  54.     return 0;
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement