Submission #6519432


Source Code Expand

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& val) {
	debug(val, true);
}

template<typename T>
void debug(vector<T>& val, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, val.size()) {
		if (i != 0) cout << ",";
		debug(val[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& val) {
	debug(val, true);
}

template<typename T, typename U>
void debug(pair<T, U>& val, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(val.first, false);
	cout << ",";
	debug(val.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

ll N;

void solve() {
	cin >> N;

	ll bin = 0;
	rep(i, N) {
		ll input;
		cin >> input;
		bin |= input;
		debug(bin);
	}

	ll ans = 0;
	while (1) {
		if (bin & 1 == 1) break;
		ans++;
		bin >>= 1;
	}

	cout << ans;

}

int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}

Submission Info

Submission Time
Task B - Shift only
User huma17
Language C++14 (Clang 3.8.0)
Score 0
Code Size 1921 Byte
Status CE

Compile Error

./Main.cpp:88:11: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
                if (bin & 1 == 1) break;
                        ^~~~~~~~
./Main.cpp:88:11: note: place parentheses around the '==' expression to silence this warning
                if (bin & 1 == 1) break;
                        ^
                          (     )
./Main.cpp:88:11: note: place parentheses around the & expression to evaluate it first
                if (bin & 1 == 1) break;
                        ^
                    (      )
./Main.cpp:30:2: error: call to function 'debug' that is neither visible in the template definition nor found by argument-dependent lookup
        debug(obj, true);
        ^
./Main.cpp:83:3: note: in instantiation of function template specialization 'debug<long long>' requested here
                debug(bin);
                ^
./Main.cpp:34:6: note: 'debug' should be declared prior to the call site
void debug(T& obj, bool lnFlag) {
     ^
1 warning and 1 error gene...