結果
| 問題 |
No.241 出席番号(1)
|
| ユーザー |
IL_msta
|
| 提出日時 | 2015-07-10 23:47:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,891 bytes |
| コンパイル時間 | 560 ms |
| コンパイル使用メモリ | 86,100 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-08 02:21:54 |
| 合計ジャッジ時間 | 1,709 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 1 |
ソースコード
#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;
}
IL_msta