結果

問題 No.123 カードシャッフル
ユーザー ramia777
提出日時 2022-12-22 17:16:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 3,561 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 102,888 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 03:23:05
合計ジャッジ時間 1,345 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

// yukicodr
// No.123
//
//vector <vector <int>> mass;
//vector <vector <int>> memo;
//vector <int> memo;
//#include "stdafx.h"
#include <iostream>
#include <vector>
#include <list>//list
#include <queue> //queue
#include <set> //()(Key)keyO(logN)
#include <map> //()(Key,data)keydataO(logN)
#include <unordered_set> //hashO(1)
#include <unordered_map> //hashO(1)
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <climits>
#include <math.h>
//#include <bits/stdc++.h>
using namespace std;
#define FOR(x,to) for(x=0;x<to;x++)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FMAX(a,b) ((a)>(b)?(a):(b))
#define FMIN(a,b) ((a)<(b)?(a):(b))
#define FCEIL(a,b) ((a)+(b)-1)/(b)
typedef unsigned long long ULL;
typedef signed long long SLL;
queue<int> _queue;
//
int compare_up(const int * a, const int *b)
{
if (*a > *b)
return (1);
else if (*a < *b)
return (-1);
return (0);
}
//
int compare_down(const int * a, const int *b)
{
if (*a > *b)
return (-1);
else if (*a < *b)
return (1);
return (0);
}
int par[3005 * 3005]; //
int _rank[3005 * 3005]; //
int flag[3005 * 3005];
//
//
int _find(int x)
{
if (x == par[x])
{
//cout << "x=" << x << endl;
return x;
}
else
{
int a;
//cout << "in->" << endl;
a = _find(par[x]);
//cout << "<-out" << endl;
//cout << "x=" << x << ",par[x]=" << par[x] << ",a=" << a << endl;
//
par[x] = a;
//
return par[x];
}
}
//xy
bool same(int x, int y)
{
//OK
return _find(x) == _find(y);
}
//
//
void init(int n)
{
for (int i = 0; i < n; i++)
{
par[i] = i;
_rank[i] = 0;
}
}
// x y
void _union(int x, int y)
{
int root_x;
int root_y;
root_x = _find(x);
root_y = _find(y);
if (root_x == root_y) return; //
//
if (_rank[root_x] < _rank[root_y])
{
// x<y
par[root_x] = root_y;
}
else
{
// x>y x==y
// yx
par[root_y] = root_x;
//
if (_rank[root_x] == _rank[root_y])
_rank[root_x]++; //
}
}
//
static ULL Gcd(ULL a, ULL b)
{
if (a < b)
//
return Gcd(b, a);
while (b != 0) {
ULL remainder = a % b;
a = b;
b = remainder;
}
return a;
}
//
static ULL Lcm(ULL a, ULL b)
{
return a * b / Gcd(a, b);
}
int solve(int i, ULL index_flag)
{
return 0;
}
int main()
{
int N, M;
int C[51];
cin >> N;
for (int i=1;i<=N;i++)
{
C[i] = i;
}
cin >> M;
for (int i=0;i<M;i++)
{
int a,top;
cin >> a;
top = C[a];
for(int j=a; j>=1; j--)
{
C[j] = C[j - 1];
}
C[1] = top;
}
cout << C[1] << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0