結果
| 問題 |
No.662 スロットマシーン
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2018-01-18 05:56:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 1,778 bytes |
| コンパイル時間 | 751 ms |
| コンパイル使用メモリ | 70,020 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 10:57:29 |
| 合計ジャッジ時間 | 1,836 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘void read(int)’:
main.cpp:48:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
48 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
ソースコード
#include<stdio.h>
#include<string>
#include<map>
#include<iostream>
#include<string.h>
const int LIMIT=5000;
const int M=5;
std::map<std::string,int> strToNo;
long long int ansC[M]={0,0,0,0,0};
long long int counts[3][M][M][M];
double ans=0;
int as[3][3];
int noToCoin[M];
int cols[3][LIMIT];
int colSize[3];
void f(long long int p){
int a=as[0][0];
if((a==as[0][1])&&(a==as[0][2])){
ansC[a]+=p;
ans+=p*noToCoin[a];
}
a=as[1][0];
if((a==as[1][1])&&(a==as[1][2])){
ansC[a]+=p;
ans+=p*noToCoin[a];
}
a=as[2][0];
if((a==as[2][1])&&(a==as[2][2])){
ansC[a]+=p;
ans+=p*noToCoin[a];
}
a=as[0][0];
if((a==as[1][1])&&(a==as[2][2])){
ansC[a]+=p;
ans+=p*noToCoin[a];
}
a=as[2][0];
if((a==as[1][1])&&(a==as[0][2])){
ansC[a]+=p;
ans+=p*noToCoin[a];
}
}
void read(int col){
int n;
scanf("%d",&n);
colSize[col]=n;
for(int i=0;i<n;i++){
std::string str;
std::cin>>str;
cols[col][i]=strToNo[str];
}
}
void regist(int no){
int c=colSize[no];
for(int i=0;i<c;i++){
int a1=cols[no][i];
int a2=cols[no][(i+1)%c];
int a3=cols[no][(i+2)%c];
counts[no][a1][a2][a3]++;
}
}
void search(int deep,long long int perm){
if(deep==3){
f(perm);
}else{
for(int i=0;i<M;i++){
as[0][deep]=i;
for(int j=0;j<M;j++){
as[1][deep]=j;
for(int k=0;k<M;k++){
as[2][deep]=k;
search(deep+1,perm*counts[deep][i][j][k]);
}
}
}
}
}
int main(){
memset(counts,0,sizeof(counts));
for(int i=0;i<M;i++){
std::string str;
int coin;
std::cin>>str>>coin;
noToCoin[i]=coin;
strToNo[str]=i;
}
read(0);
read(1);
read(2);
regist(0);
regist(1);
regist(2);
search(0,1);
double all=colSize[0];
all*=colSize[1];
all*=colSize[2];
printf("%lf\n",ans/all);
for(int i=0;i<M;i++){
std::cout<<ansC[i]<<std::endl;
}
}
horiesiniti