Submission #1195852


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;
vector<int> A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	if((N&(N+1))==0) {
		x=0;
		while(N) A.push_back(++x),N/=2;
		
		_P("%d\n",x*2);
		FOR(i,x) _P("%d ",A[i]);
		FOR(i,x) _P("%d%c",A[i],(i==x-1)?'\n':' ');
	}
	else {
		ll T=N/2;
		x=0;
		while(T) A.push_back(++x),T/=2;
		B=A;
		N -= (1LL<<x)-1;
		vector<int> C;
		y=x+1;
		FOR(i,A.size()) {
			C.push_back(A[i]);
			if(N&(1LL<<(x-1-i))) {
				C.push_back(y);
				B.insert(B.begin(),y);
				y++;
			}
		}
		_P("%d\n",B.size()+C.size());
		FORR(r,C) _P("%d ",r);
		FOR(i,B.size()) _P("%d%c",B[i],(i==B.size()-1)?'\n':' ');
		
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}

Submission Info

Submission Time
Task C - Tautonym Puzzle
User kmjp
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 1329 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:6:41: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<int>::size_type {aka long unsigned int}’ [-Wformat=]
 #define _P(...) (void)printf(__VA_ARGS__)
                                         ^
./Main.cpp:46:3: note: in expansion of macro ‘_P’
   _P("%d\n",B.size()+C.size());
   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 2
AC × 32
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