Submission #655597
Source Code Expand
#include<iostream> #include<map> #include<vector> #include<algorithm> #include<cmath> #include<iomanip> #include<numeric> #include<climits> #include<ctime> #include<cstring> #include<sstream> #define REP(i,p,n) for(int i=p;i<(int)(n);i++) #define rep(i,n) REP(i,0,n) #define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re)) #define ALL(c) (c).begin(), (c).end() #define dump(a) cerr << #a << "=" << (a) << endl #define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl; template<class T> void chmin(T &t, T f) { if (t > f) t = f; } //t=min template<class T> void chmax(T &t, T f) { if (t < f) t = f; } //t=max using namespace std; int A[ 100000 + 10 ]; int main() { int N,M,D; cin >> N >> M >> D; int doubling[N+1][31]; rep(i,M) { cin >> A[ i ]; } for(int i = 1; i <= n; ++i) doubling[ i ][ 0 ] = i; //阿弥陀のシュミレーション for(int i = m - 1; i >= 0; --i){ swap(doubling[A[i]][0],to[A[i]+1][0]); } REP(k,1,30) { //2^1 ~ 2^30 REP(i,1,N+1) { int f = doubling[ i ][ k - 1 ]; doubling[i][k] = doubling[f][k-1]; } } //ダブリング:工程2 REP(i,1,N+1) { int next = i; int DD = D; rep(k,30+1) { if (DD & 1) { next = doubling[next][k]; } DD = DD >> 1; } cout << next << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 阿弥陀 |
User | Ow1 |
Language | C++11 (GCC 4.8.1) |
Score | 0 |
Code Size | 1463 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:35:25: error: ‘n’ was not declared in this scope for(int i = 1; i <= n; ++i) ^ ./Main.cpp:39:17: error: ‘m’ was not declared in this scope for(int i = m - 1; i >= 0; --i){ ^ ./Main.cpp:40:26: error: ‘to’ was not declared in this scope swap(doubling[A[i]][0],to[A[i]+1][0]); ^