結果
| 問題 | No.123 カードシャッフル |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-30 02:20:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 5,000 ms |
| コード長 | 340 bytes |
| コンパイル時間 | 2,080 ms |
| コンパイル使用メモリ | 194,972 KB |
| 最終ジャッジ日時 | 2025-01-09 10:57:36 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | int n,q; scanf("%d%d",&n,&q);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:13:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | int x; scanf("%d",&x); x--;
| ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
int n,q; scanf("%d%d",&n,&q);
vector<int> a(n);
rep(i,n) a[i]=i;
rep(_,q){
int x; scanf("%d",&x); x--;
vector<int> b(n);
b[0]=a[x];
int idx=1;
rep(i,n) if(i!=x) b[idx++]=a[i];
a=b;
}
printf("%d\n",a[0]+1);
return 0;
}