結果
問題 | No.123 カードシャッフル |
ユーザー |
![]() |
提出日時 | 2018-02-05 16:31:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 5,000 ms |
コード長 | 744 bytes |
コンパイル時間 | 719 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-08 00:06:28 |
合計ジャッジ時間 | 1,510 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:46:21: warning: 'dp' may be used uninitialized [-Wmaybe-uninitialized] 46 | cout << dp[1] << endl; | ^ main.cpp:27:13: note: 'dp' declared here 27 | int dp[51]; | ^~
ソースコード
#include<iostream>#include<string>#include<string.h>#include<algorithm>#include<stdio.h>#include<cmath>#include<vector>#include<utility>#include<stack>#include<queue>#include<list>#include<bitset>#include<functional>#define FOR(i, a, b) for(int i=(a);i<=(b);i++)#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)#define MOD 1000000007#define INF 1000000000#define PI 3.14159265358979using namespace std;typedef pair<int, int> P;int main(void) {int n, m;int a[100001];int dp[51];int tmp;int tell;cin >> n >> m;FOR(i, 1, m) {cin >> a[i];}FOR(i, 1, n) {dp[i] = i;}FOR(i, 1, m) {tmp = dp[a[i]];RFOR(t, a[i],2) {dp[t] = dp[t - 1];}dp[1] = tmp;}cout << dp[1] << endl;return 0;}