結果
| 問題 |
No.241 出席番号(1)
|
| コンテスト | |
| ユーザー |
IL_msta
|
| 提出日時 | 2015-07-12 02:20:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,146 bytes |
| コンパイル時間 | 957 ms |
| コンパイル使用メモリ | 89,532 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-08 05:49:56 |
| 合計ジャッジ時間 | 3,458 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 RE * 4 |
ソースコード
#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(6);//
int N;
cin>>N;
int A[50];
int U[50];
int Umax = 0;
int UmaxNo = -1;
rep(i,50)U[i]=0;
rep(i,N){
cin>>A[i];
++U[ A[i] ];
if( Umax < U[ A[i] ] ){
Umax = U[ A[i] ];
UmaxNo = A[i];
}
}
rep(i,N){
if(U[i] == N){
P(-1);
return 0;
}
}
vector<int> No;
if( Umax > N/2){
rep(i,N){
if(A[i] != UmaxNo){
//iにUmaxNo
int pipo=0;
rep(j,i){
if(j==UmaxNo)pipo=1;
No.push_back(j+pipo);
}
No.push_back(UmaxNo);
pipo=1;
for(int j=i+1;j<N;++j){
if(j>UmaxNo)pipo=0;
No.push_back(j-pipo);
}
break;
}
}
}else{
rep(i,N){
No.push_back(i);
}
}
int num;
bool use[50];
bool make;
do{
make = false;
/*rep(i,N){
cout << No[i] << " ";
}
cout << endl;
*/
num = -1;
rep(i,N){
if(A[i] == No[i]){
num = i;
break;
}
}
if(num == -1){
break;
}
for(;;)
{
if(No[num] < N-1){
rep(i,N) use[i] = false;
++No[num];
rep(i,num){
use[ No[i] ] = true;
}
while( No[num] < N && use[ No[num] ] == true)
{++No[num];}
if( No[num] < N){
use[ No[num] ] = true;
for(int i = num+1;i<N;++i){
rep(j,N){
if(use[j] == false){
No[i] = j;
use[j] = true;
break;
}
}
}
make = true;
break;
}
}
if( No[num] >= N-1){
--num;
if(num < 0){
P(-1);
return 0;
}
}
}
}while( make==true || next_permutation(No.begin(),No.end()) );
rep(i,N)P(No[i]);
return 0;
}
IL_msta