結果

問題 No.2881 Mod 2^N
コンテスト
ユーザー shobonvip
提出日時 2024-09-20 01:33:24
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 959 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,164 ms
コンパイル使用メモリ 220,716 KB
実行使用メモリ 16,768 KB
最終ジャッジ日時 2026-07-05 17:46:34
合計ジャッジ時間 3,439 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' [-Wc++20-extensions]
    6 | bool chmin(auto &a, auto b){ return a > b ? a = b, 1 : 0; }
      |            ^~~~
main.cpp:6:21: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' [-Wc++20-extensions]
    6 | bool chmin(auto &a, auto b){ return a > b ? a = b, 1 : 0; }
      |                     ^~~~
main.cpp:7:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' [-Wc++20-extensions]
    7 | bool chmax(auto &a, auto b){ return a < b ? a = b, 1 : 0; }
      |            ^~~~
main.cpp:7:21: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' [-Wc++20-extensions]
    7 | bool chmax(auto &a, auto b){ return a < b ? a = b, 1 : 0; }
      |                     ^~~~

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define all(v) begin(v),end(v)
using namespace std;
using ll = long long;
bool chmin(auto &a, auto b){ return a > b ? a = b, 1 : 0; }
bool chmax(auto &a, auto b){ return a < b ? a = b, 1 : 0; }
int main(){
    cin.tie(0)->sync_with_stdio(0);

	ll n,x,y;
	cin >> n >> x >> y;
	if (x==y){
		cout << 0 << '\n';
		return 0;
	}

	if ((y&1) == 0) {
		cout << -1 << '\n';
		return 0;
	}

	deque<ll> bits(n);
	rep(i,0,n){
		bits[n-1-i] = (y>>i&1);
	}

	while(bits.front() == 0) {
		bits.pop_front();
	}
	bits.pop_front();
	
	vector<ll> ls;
	while(!bits.empty()){
		int cnt = 0;
		while(bits.front() == 0) {
			cnt++;
			bits.pop_front();
		}
		cnt++;
		bits.pop_front();
		ls.push_back(cnt);
	}

	
	vector<ll> a;
	a.push_back(n);
	rep(i,0,(int)ls.size()){
		a.push_back(ls[i]);
	}

	cout << (int)a.size() << '\n';
	rep(i,0,(int)a.size()){
		cout << a[i] << ' ';
	}
	cout << '\n';

}
0