Guest User

Untitled

a guest
Sep 22nd, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1. #include <stdio.h>
  2.     #include <string.h>
  3.     #include <math.h>
  4.     #include <algorithm>
  5.     #include <map>
  6.     #include <vector>
  7.     #include <ctype.h>
  8.     #include <set>
  9.      
  10.     using namespace std;
  11.      
  12.     int main()
  13.     {  
  14.             int a[101] = {0};
  15.             int b[101] = {0};
  16.             int c[3][101];
  17.            
  18.             int n;
  19.             int i,j,k;
  20.             scanf("%d",&n);
  21.            
  22.             int q;
  23.             q = (n+1)/2;
  24.            
  25.             for(i=1;i<=q;++i)
  26.             {
  27.                     for(j=1;j<=n;++j)
  28.                     {
  29.                             c[1][j] = c[2][j];
  30.                             c[2][j] = 0;
  31.                     }
  32.                    
  33.                     printf("Q %d %d\n",i,i+q-1);
  34.                     fflush(stdout);
  35.                    
  36.                     for(j=1;j<=q;++j)
  37.                     {
  38.                             scanf("%d",&k);
  39.                             b[k]++;
  40.                             c[2][k] = 1;
  41.                     }
  42.                    
  43.                     if(i!=1)
  44.                     {
  45.                             for(j=1;j<=n;++j)
  46.                                     if(c[1][j] == 1 && c[2][j] == 0)
  47.                                             a[i-1] = j;
  48.                                     else if(c[1][j] == 0 && c[2][j] == 1)
  49.                                             a[i+q-1] = j;
  50.                     }
  51.      
  52.                     if(i == q)
  53.                     {
  54.                             for(j=1;j<=n;++j)
  55.                                     if(b[j] == q)
  56.                                             a[q] = j;
  57.                                     else if(b[j] == 0)
  58.                                             a[n] = j;
  59.                     }
  60.                    
  61.             }
  62.            
  63.             printf("A ");
  64.             fflush(stdout);
  65.             for(i=1;i<=n;++i)
  66.             {
  67.                     printf("%d ",a[i]);
  68.                     fflush(stdout);
  69.             }
  70.      puts("");
  71.                     fflush(stdout);
  72.             return 0;
  73.     }
Advertisement
Add Comment
Please, Sign In to add comment