Always read the problem fully , specially if there are something in bold / mathematical form never miss those .
This problem created enough confusion when taking input for k.
Had some confusing thoughts .
For some player , win_average = his_win/(his_win+his_lose)
When , N = 2
We can write ,
win_average = his_win/(his_win+his_lose)
= his_wins/total_match
But, this doesn't apply when N>2 .
This problem created enough confusion when taking input for k.
Had some confusing thoughts .
For some player , win_average = his_win/(his_win+his_lose)
When , N = 2
We can write ,
win_average = his_win/(his_win+his_lose)
= his_wins/total_match
But, this doesn't apply when N>2 .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | /**************************************** @_@ Cat Got Bored *_* #_# *****************************************/ #include <bits/stdc++.h> #define loop(i,s,e) for(int i = s;i<=e;i++) //including end point #define pb(a) push_back(a) #define sqr(x) ((x)*(x)) #define CIN ios_base::sync_with_stdio(0); cin.tie(0); #define ll long long #define ull unsigned long long #define SZ(a) int(a.size()) #define read() freopen("input.txt", "r", stdin) #define write() freopen("output.txt", "w", stdout) #define ms(a,b) memset(a, b, sizeof(a)) #define all(v) v.begin(), v.end() #define PI acos(-1.0) #define pf printf #define sfi(a) scanf("%d",&a); #define sfii(a,b) scanf("%d %d",&a,&b); #define sfl(a) scanf("%lld",&a); #define sfll(a,b) scanf("%lld %lld",&a,&b); #define sful(a) scanf("%llu",&a); #define sfulul(a,b) scanf("%llu %llu",&a,&b); #define sful2(a,b) scanf("%llu %llu",&a,&b); // A little different #define sfc(a) scanf("%c",&a); #define sfs(a) scanf("%s",a); #define mp make_pair #define paii pair<int, int> #define padd pair<dd, dd> #define pall pair<ll, ll> #define fs first #define sc second #define CASE(t) printf("Case #%d: ",++t) // t initialized 0 #define cCASE(t) cout<<"Case "<<++t<<": "; #define INF 1000000000 //10e9 #define EPS 1e-9 #define flc fflush(stdout); //For interactive programs , flush while using pf (that's why __c ) using namespace std; //Remove this before submission int num_wins[10009]; int num_loss[1009]; inline int win_pl(int mv1,int mv2) { if(mv1==mv2) return 0; if(mv1==1 && mv2==2) return 2; if(mv1==2 && mv2==3) return 2; if(mv1==1 && mv2==3) return 1; if(mv1==2 && mv2==1) return 1; if(mv1==3 && mv2==2) return 1; if(mv1==3 && mv2==1) return 2; return 0; } inline int prser(char ss[]) { if(strcmp(ss,"rock")==0) return 1; if(strcmp(ss,"paper")==0) return 2; if(strcmp(ss,"scissors")==0) return 3; } int main() { //write(); int n,k; int cas = 0; while(true) { sfi(n); if(n==0) break; if(cas!=0) pf("\n"); cas++; sfi(k); ms(num_wins,0); ms(num_loss,0); int num_mtc = 0; loop(i,1,(k*n*(n-1))/2) { int plyer1; char tke1[20]; int plyer2; char tke2[20]; //cin>>plyer1>>tke1; sfi(plyer1); sfs(tke1); sfi(plyer2); sfs(tke2); //cin>>plyer2>>tke2; //cout<<plyer1<<" "<<plyer2<<endl; //cout<<tke1<<" "<<tke2<<endl; //cout<<prser[tke1]<<" "<<prser[tke2]<<endl; if(win_pl(prser(tke1),prser(tke2))==1) { num_wins[plyer1]++; num_loss[plyer2]++; num_mtc++; } else if(win_pl(prser(tke1),prser(tke2))==2) { num_wins[plyer2]++; num_loss[plyer1]++; num_mtc++; } } //cout<<"La"<<endl; loop(i,1,n) { if(num_wins[i]+num_loss[i]==0) { pf("-\n"); } else { double wn = (double)(num_wins[i]*1.000)/( (num_wins[i]+ num_loss[i])*1.00); pf("%.3lf\n",wn); } } } return 0; } |