結果

問題 No.241 出席番号(1)
ユーザー IL_mstaIL_msta
提出日時 2015-07-10 23:47:30
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,891 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 85,584 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 10:24:36
合計ジャッジ時間 2,531 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;

#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    cout << setprecision(10);//

	bool b[50][50];
	int N;
	cin>>N;
	rep(i,N)rep(j,N){
		b[i][j] = false;
	}
	int A[50];
	int bb[50];
	rep(i,50)bb[i]=0;
	rep(i,N){
		cin>>A[i];
		b[i][A[i]] = true;
		++bb[A[i]];
	}
	bool used[50];
	bool usedNo[50];
	rep(i,N){
		used[i]=false;
		usedNo[i] = false;
	}
	//////////
	int ans[50];
	rep(i,N)ans[i]=-1;
	int max=0;
	int maxNo;
	int nokori = N;
	for(int count=0;count<N;++count)
	{
		max = 0;
		maxNo = -1;
		rep(i,N){
			if(max < bb[i] ){
				max = bb[i];
				maxNo = i;
			}
		}
		if( max == nokori){
			P(-1);
			return 0;
		}
		--nokori;
		if(max == 0){
			rep(i,N){
				if(used[i] == false){
					rep(k,N){
						if(usedNo[k] == false){
							ans[i] = k;
							used[i] = true;
							usedNo[k] = true;
							break;
						}
					}
				}
			}
			break;
		}
		else if(max == 1){
			rep(i,N){
				if( ans[i] == -1){
					rep(k,N){
						if( usedNo[((A[i]+k+1)%N)] == false){
							ans[i] = ((A[i]+k+1)%N);
							usedNo[((A[i]+k+1)%N)] = true;
							used[i] = true;
							break;
						}
					}
				}
			}
			break;
		}
		else{
			bb[maxNo] = 0;
			rep(i,N){
				if(b[i][maxNo] == false && used[i] == false){
					used[i] = true;
					usedNo[maxNo] = true;
					ans[i] = maxNo;
					break;
				}	
			}
		}
	}
	rep(i,N){
		P(ans[i]);
	}
    return 0;
}
0