Guest User

Untitled

a guest
May 13th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int id(char u) {
  7.     return (int) (u - 'A');
  8. }
  9.  
  10. char tag(int i) {
  11.     return (char) (i + 'A');
  12. }
  13.  
  14. vector<int> a;
  15. vector<vector<int> > b;
  16. vector<int> c;
  17.  
  18. int main() {
  19.     int t, f;
  20.     scanf("%d %d", &t, &f);
  21.  
  22.     for (int ca = 1; ca <= t; ca ++) {
  23.        
  24.         char u;
  25.        
  26.         a = vector<int> (5, 0);
  27.         b = vector<vector<int> > (5);
  28.  
  29.         string ans = "";
  30.  
  31.         for (int i = 1; i <= 595; i ++) {
  32.             printf("%d", i);
  33.             fflush(stdout);
  34.             scanf("%c ", &u);
  35.             a[id(u)] ++;
  36.             b[id(u)].push_back(i);
  37.         }
  38.  
  39.         int p[] = {19, 5, 1};
  40.  
  41.         for (int pi = 0; pi < 3; pi ++) {
  42.             int cur = p[pi];
  43.  
  44.             int nid;
  45.  
  46.             for (int i = 0;  i < 5; i ++) {
  47.                 if (a[i] == cur) {
  48.                     ans += tag(i);
  49.                     nid = i;
  50.                     break;
  51.                 }
  52.             }
  53.  
  54.             c = vector<int> (b[nid].begin(), b[nid].end());
  55.             a.clear();
  56.             a = vector<int> (5, 0);
  57.             b.clear();
  58.             b = vector<vector<int> > (5);
  59.  
  60.             for (auto x: c) {
  61.                 int i = x + 1;
  62.                 printf("%d", i);
  63.                 fflush(stdout);
  64.                 scanf("%c ", &u);
  65.                 a[id(u)] ++;
  66.                 b[id(u)].push_back(i);
  67.             }
  68.         }
  69.  
  70.         for (int i = 0 ;  i < 5; i ++) {
  71.             if (a[i] == 1) {
  72.                 printf("%d", b[i][0]);
  73.                 fflush(stdout);
  74.                 scanf("%c ", &u);
  75.                 ans += u;
  76.                 ans += tag(i);
  77.                 break;
  78.             }
  79.         }
  80.        
  81.         printf("%s", ans.c_str());
  82.         fflush(stdout);
  83.  
  84.         scanf("%c ", &u);
  85.         if (u == 'N') break;
  86.  
  87.     }
  88.  
  89.     return 0;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment