Submission #1194950
Source Code Expand
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
int main() {
ll n;
scanf("%lld",&n);
int m = 1;
vi s;
deque<int> a;
while (n) {
if (n&1) {
s.pb(0);
n >>= 1;
} else {
s.pb(1);
n -= 1;
}
}
drep(i,sz(s)) {
if (s[i]) a.push_front(m++);
else a.pb(m++);
}
rrep(i,m-1) a.pb(i);
vi ans;
rep(i,sz(a)) ans.pb(a[i]);
cout<<sz(ans)<<endl;
cout<<ans<<endl;
return 0;
}
Submission Info
Submission Time
2017-04-01 21:17:41+0900
Task
C - Tautonym Puzzle
User
snuke
Language
C++14 (GCC 5.4.1)
Score
1000
Code Size
2655 Byte
Status
AC
Exec Time
1 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:70:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&n);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
1000 / 1000
Status
Set Name
Test Cases
Sample
00_example_01.txt, 00_example_02.txt
All
00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt
Case Name
Status
Exec Time
Memory
00_example_01.txt
AC
1 ms
256 KB
00_example_02.txt
AC
1 ms
256 KB
01.txt
AC
1 ms
256 KB
02.txt
AC
1 ms
256 KB
03.txt
AC
1 ms
256 KB
04.txt
AC
1 ms
256 KB
05.txt
AC
1 ms
256 KB
06.txt
AC
1 ms
256 KB
07.txt
AC
1 ms
256 KB
08.txt
AC
1 ms
256 KB
09.txt
AC
1 ms
256 KB
10.txt
AC
1 ms
256 KB
11.txt
AC
1 ms
256 KB
12.txt
AC
1 ms
256 KB
13.txt
AC
1 ms
256 KB
14.txt
AC
1 ms
256 KB
15.txt
AC
1 ms
256 KB
16.txt
AC
1 ms
256 KB
17.txt
AC
1 ms
256 KB
18.txt
AC
1 ms
256 KB
19.txt
AC
1 ms
256 KB
20.txt
AC
1 ms
256 KB
21.txt
AC
1 ms
256 KB
22.txt
AC
1 ms
256 KB
23.txt
AC
1 ms
256 KB
24.txt
AC
1 ms
256 KB
25.txt
AC
1 ms
256 KB
26.txt
AC
1 ms
256 KB
27.txt
AC
1 ms
256 KB
28.txt
AC
1 ms
256 KB
29.txt
AC
1 ms
256 KB
30.txt
AC
1 ms
256 KB