結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー | itezpace |
提出日時 | 2016-07-16 00:14:37 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 1,379 bytes |
コンパイル時間 | 1,280 ms |
コンパイル使用メモリ | 151,756 KB |
実行使用メモリ | 24,360 KB |
平均クエリ数 | 80.44 |
最終ジャッジ日時 | 2023-09-24 00:18:58 |
合計ジャッジ時間 | 2,851 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
24,276 KB |
testcase_01 | AC | 23 ms
23,664 KB |
testcase_02 | AC | 22 ms
24,024 KB |
testcase_03 | AC | 23 ms
24,060 KB |
testcase_04 | AC | 22 ms
24,036 KB |
testcase_05 | AC | 22 ms
23,664 KB |
testcase_06 | AC | 25 ms
24,168 KB |
testcase_07 | AC | 22 ms
23,664 KB |
testcase_08 | AC | 22 ms
23,616 KB |
testcase_09 | AC | 23 ms
24,360 KB |
testcase_10 | AC | 22 ms
23,652 KB |
testcase_11 | AC | 22 ms
24,060 KB |
testcase_12 | AC | 23 ms
23,784 KB |
testcase_13 | AC | 24 ms
23,376 KB |
testcase_14 | AC | 24 ms
24,360 KB |
testcase_15 | AC | 24 ms
23,580 KB |
testcase_16 | AC | 23 ms
23,424 KB |
testcase_17 | AC | 21 ms
23,424 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:44:13: warning: ‘pos’ may be used uninitialized in this function [-Wmaybe-uninitialized] int pos; ^~~ main.cpp:25:13: warning: ‘pos’ may be used uninitialized in this function [-Wmaybe-uninitialized] int pos; ^~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int n,a,d; cin>>n; vector<int> v; for(int i=0; i<n; ++i){ cin>>a; v.push_back(a); } int f; int c; c=0; vector<pair<int,int>> vp; while(1){ f=0; for(int i=1; i<n-1; ++i){ int x,y,z; x=v[i-1]; y=v[i]; z=v[i+1]; if(x<y && y>z){ int pos; for(int j=n-1; j>=0; --j){ if(y>v[j]){ pos=j; break; } } v.erase(v.begin()+i); v.insert(v.begin()+i,v[pos-1]); v.erase(v.begin()+pos); v.insert(v.begin()+pos,y); f=1; c++; pair<int,int> p; p=make_pair(i,pos); vp.push_back(p); break; } if(x>y && y<z){ int pos; for(int j=0; j<n; ++j){ if(y<v[j]){ pos=j; break; } } v.erase(v.begin()+i); v.insert(v.begin()+i,v[pos]); v.erase(v.begin()+pos); v.insert(v.begin()+pos,y); f=1; c++; pair<int,int> p; p=make_pair(pos,i); vp.push_back(p); break; } } if(f==0){ break; } } cout<<c<<endl; pair<int,int> p; for(int i=0; i<vp.size(); ++i){ p=vp[i]; cout<<p.first<<" "<<p.second<<endl; } cin>>d; return 0; }