結果

問題 No.241 出席番号(1)
ユーザー IL_mstaIL_msta
提出日時 2015-07-12 01:38:00
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,622 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 89,400 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-22 14:11:26
合計ジャッジ時間 6,375 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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(6);//

    int N;
	cin>>N;
	int A[50];
	rep(i,N){
		cin>>A[i];
	}

	vector<int> No;
	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;
}
0