結果

問題 No.1537 私の代わりに仕事やっといてください。
ユーザー spipipikespipipike
提出日時 2021-06-06 20:20:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 1,816 ms
コンパイル使用メモリ 174,572 KB
実行使用メモリ 7,428 KB
最終ジャッジ日時 2023-08-17 19:01:38
合計ジャッジ時間 3,014 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 119 ms
7,428 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 11 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:32:17: 警告: ‘s’ may be used uninitialized [-Wmaybe-uninitialized]
   32 |                 if((i+1)%n==s) break;;
      |                 ^~
main.cpp:26:13: 備考: ‘s’ はここで定義されています
   26 |         int s;
      |             ^

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	cin>>n;
	vector<P> ai(n);
	rep(i, n){
		int a;
		cin>>a;
		ai[i]=P(a, i);
	}

	sort(ai.begin(), ai.end());
	vector<int> b, c;
	rep(i, n){
		if(i%2==0) b.push_back(ai[i].second);
		else c.push_back(ai[i].second);
	}
	reverse(c.begin(), c.end());
	for(int e : b) c.push_back(e);

	int s;
	rep(i, n) if(c[i]==0) s=i;

	vector<int> ans;
	for(int i=s; ; i=(i+1)%n){
		ans.push_back(c[i]);
		if((i+1)%n==s) break;;
	}

	for(int e : ans) cout<<(e+1)<<" ";
	cout<<1<<endl;
	return 0;
}
0