SHOW:
|
|
- or go back to the newest paste.
| 1 | #include<stdio.h> | |
| 2 | #include<string.h> | |
| 3 | #include<math.h> | |
| 4 | #include<ctype.h> | |
| 5 | #include<stdlib.h> | |
| 6 | #include<cstdio> | |
| 7 | #include<cstring> | |
| 8 | #include<string> | |
| 9 | #include<cmath> | |
| 10 | #include<iostream> | |
| 11 | #include<cctype> | |
| 12 | #include<map> | |
| 13 | #include<stack> | |
| 14 | #include<cstdlib> | |
| 15 | - | #include <queue> |
| 15 | + | #include<queue> |
| 16 | - | #include <vector> |
| 16 | + | #include<vector> |
| 17 | #include<algorithm> | |
| 18 | #include<bitset> | |
| 19 | #include<algorithm> | |
| 20 | #include<set> | |
| 21 | #include<limits.h> | |
| 22 | ||
| 23 | using namespace std; | |
| 24 | typedef long int LD; | |
| 25 | typedef long long int LLD; | |
| 26 | typedef float F; | |
| 27 | typedef double LF; | |
| 28 | typedef unsigned int U; | |
| 29 | typedef unsigned long int LU; | |
| 30 | typedef unsigned long long int LLU; | |
| 31 | typedef char C; | |
| 32 | ||
| 33 | #define sf scanf | |
| 34 | - | #define MAX(x,y) (x>y)?x:y |
| 34 | + | #define sfi(x) scanf("%d",&x)
|
| 35 | - | #define MIN(x,y) (x<y)?x:y |
| 35 | + | #define sfc(x) scanf("%c",&x)
|
| 36 | - | #define MAX3(x,y,z) (x>y)?((x>z)?x:z):((y>z)?((y>x)?y:x):z) |
| 36 | + | #define sfi2(x,y) scanf("%d%d",&x,&y)
|
| 37 | - | #define MIN3(x,y,z) (x<y)?((x<z)?x:z):((y<z)?((y<x)?y:x):z) |
| 37 | + | #define sfl(x) scanf("%ld",&x)
|
| 38 | #define sfll(x) scanf("%lld",&x)
| |
| 39 | - | //#define sz 1005 |
| 39 | + | #define sfu(x) scanf("%llu",&x)
|
| 40 | #define sfs(x) scanf("%s",x)
| |
| 41 | - | /****** start your code *******/ |
| 41 | + | |
| 42 | #define pfi(x) printf("%d\n",x)
| |
| 43 | #define pfl(x) printf("%ld\n",x)
| |
| 44 | #define pfll(x) printf("%lld\n",x)
| |
| 45 | - | int n,a,b,i,nt,im,q,p,s,coun; |
| 45 | + | #define pfu(x) printf("%llu\n",x)
|
| 46 | - | while(sf("%d",&n)!=EOF)
|
| 46 | + | #define pfs(x) printf("%s\n",x)
|
| 47 | #define pfc(x) printf("%c\n",x)
| |
| 48 | - | queue<int>qu; |
| 48 | + | #define pb(x) push_back(x) |
| 49 | - | priority_queue<int>pqu; |
| 49 | + | |
| 50 | - | stack<int>stk; |
| 50 | + | |
| 51 | - | nt=im=q=p=s=coun=0; |
| 51 | + | |
| 52 | - | for(i=0; i<n; i++) |
| 52 | + | // xx-> diagonal -> 8 horizontal/vertical->4 |
| 53 | - | {
|
| 53 | + | |
| 54 | - | sf("%d%d",&a,&b);
|
| 54 | + | const int xx[] = {0, 1, 0, -1, -1, 1, -1, 1};
|
| 55 | - | switch(a) |
| 55 | + | const int yy[] = {1, 0, -1, 0, 1, 1, -1, -1};
|
| 56 | - | {
|
| 56 | + | |
| 57 | - | case 1: |
| 57 | + | // KX-> Knight moves |
| 58 | - | {
|
| 58 | + | const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
|
| 59 | - | qu.push(b); |
| 59 | + | const int ky[] = {1, 2, 2, 1, -1, -2, -2, -1};
|
| 60 | - | pqu.push(b); |
| 60 | + | |
| 61 | - | stk.push(b); |
| 61 | + | |
| 62 | - | } |
| 62 | + | /******** debug **********/ |
| 63 | - | break; |
| 63 | + | #define chk1 printf("hi......1\n")
|
| 64 | - | case 2: |
| 64 | + | #define chk2 printf("hi......2\n")
|
| 65 | - | {
|
| 65 | + | |
| 66 | - | int x,y,z; |
| 66 | + | |
| 67 | - | x=y=z=102; |
| 67 | + | |
| 68 | - | coun++; |
| 68 | + | |
| 69 | - | if(!qu.empty()) |
| 69 | + | #define mod 1000003 |
| 70 | - | {
|
| 70 | + | #define eps 10e-8 |
| 71 | - | x=qu.front(); |
| 71 | + | #define sz 1002 |
| 72 | - | qu.pop(); |
| 72 | + | #define sz1 1004 |
| 73 | - | } |
| 73 | + | #define sz2 15 |
| 74 | - | if(!pqu.empty()) |
| 74 | + | /******* start my code ********/ |
| 75 | - | {
|
| 75 | + | class data |
| 76 | - | y=pqu.top(); |
| 76 | + | |
| 77 | - | pqu.pop(); |
| 77 | + | public: |
| 78 | - | } |
| 78 | + | int x,y; |
| 79 | - | if(!stk.empty()) |
| 79 | + | data() |
| 80 | - | {
|
| 80 | + | |
| 81 | - | z=stk.top(); |
| 81 | + | x=y=0; |
| 82 | - | stk.pop(); |
| 82 | + | |
| 83 | - | } |
| 83 | + | }; |
| 84 | - | if((x==b && y==b)||(x==b && z==b)|| (z==b && y==b)) |
| 84 | + | data arr[sz]; |
| 85 | - | nt++; |
| 85 | + | bool compare(data a,data b) |
| 86 | - | if(x==b) |
| 86 | + | |
| 87 | - | q++; |
| 87 | + | return a.y>b.y; |
| 88 | - | if(y==b) |
| 88 | + | } |
| 89 | - | p++; |
| 89 | + | bool compare2(data a,data b) |
| 90 | - | if(z==b) |
| 90 | + | |
| 91 | - | s++; |
| 91 | + | return a.x<b.x; |
| 92 | - | if(x!=b && y!=b && z!=b) |
| 92 | + | } |
| 93 | - | im++; |
| 93 | + | |
| 94 | - | } |
| 94 | + | |
| 95 | - | //break; |
| 95 | + | int i,j,k,n; |
| 96 | - | } |
| 96 | + | bool key; |
| 97 | - | } |
| 97 | + | sfi2(n,k); |
| 98 | - | if(nt==coun) |
| 98 | + | for(i=0;i<n;i++) |
| 99 | - | pf("not sure\n");
|
| 99 | + | |
| 100 | - | else if(q==coun) |
| 100 | + | arr[i].x=i+1; |
| 101 | - | pf("queue\n");
|
| 101 | + | sfi(arr[i].y); |
| 102 | - | else if(p==coun) |
| 102 | + | |
| 103 | - | pf("priority queue\n");
|
| 103 | + | sort(arr,arr+n,compare); |
| 104 | - | else if(s==coun) |
| 104 | + | pfi(arr[k-1].y); |
| 105 | - | pf("stack\n");
|
| 105 | + | // for(i=0;i<n;i++) |
| 106 | - | else if(im==coun) |
| 106 | + | // pf("%d ",arr[i].y);nn;
|
| 107 | - | pf("impossible\n");
|
| 107 | + | sort(arr,arr+k,compare2); |
| 108 | - | else |
| 108 | + | for(i=0;i<k;i++) |
| 109 | - | pf("impossible\n");
|
| 109 | + | pf("%d ",arr[i].x);
|
| 110 | return 0; | |
| 111 | } |