24 lines
1.1 KiB
C
24 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdint.h>
|
|
|
|
typedef uint64_t u;u R=0
|
|
#define O(n,x) u n(u a, u b){return x;}
|
|
,N;u X(u n){u r=0,i=0;for(;i<n;i++){if(!(R%4))scanf(
|
|
#define l(c) for(;c; i++) {m w=d(); r.l=\
|
|
i?o[t] (r.l,w.l) :w.l;r.v+=w.v;}
|
|
"%1lx",&N);r =r<<1 | N>>3-R%4&1;R++;} return r;}
|
|
typedef struct m{u l,v ;}m;O (A,a+b)O(M,a*b)O( H,a<b
|
|
?a :b)O(J, a>b?a:b)O(G,a>b)O(L, a<b)O( E,a==b)u(* o[
|
|
])(u,u)={A,M, H,J,0,G,L,E};
|
|
m d(){m r={0,X(3)}; u t=X(3
|
|
), s,k,i=0;if(t==4)do{s=X(1) ;r
|
|
.l=r.l<<4|X(4); }while(s);else{
|
|
s=X(1);k= X(s?11:
|
|
15 );
|
|
if(s)l(i<
|
|
k)else{ k+=R;l(R<
|
|
k ) }}return r;}int
|
|
main ( ) {m r=d();
|
|
printf("Silver: %lu"
|
|
"\nGold: %lu\n",r
|
|
.v,r.l);}
|