http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0205
テスト
とりあえずAOJからやってない問題を書いた
全員おなじものを出した時の処理がかいってなかったのでWAだらけだった
#include<iostream>
using namespace std;
int main()
{
while (true){
int a[5];
int f[4] = { 0 };
for (int i = 0; i < 5; i++){
cin >> a[i];
if (i == 0 && a[i] == 0){
return 0;
}
f[a[i]]++;
}
if (f[1]>0 && f[2] > 0 && f[3] > 0 || f[1] > 4 || f[2] > 4 || f[3] > 4){
for (int i = 0; i < 5; i++){
cout << "3" << endl;
}
}
else if (f[1]>0 && f[3] > 0){
for (int i = 0; i < 5; i++){
if (a[i] == 1){
cout << "2" << endl;
}
else{
cout << "1" << endl;
}
}
}
else if (f[2] > 0 && f[3] > 0){
for (int i = 0; i < 5; i++){
if (a[i] == 3){
cout << "2" << endl;
}
else{
cout << "1" << endl;
}
}
}
else{
for (int i = 0; i < 5; i++){
cout << a[i] << endl;
}
}
}
}