Submission #6519485


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&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

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>& obj) {
	debug(obj, true);
}

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

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

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.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 200
Code Size 2225 Byte
Status AC
Exec Time 9 ms
Memory 888 KB

Compile Error

./Main.cpp:94:11: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
                if (bin & 1 == 1) break;
                        ^~~~~~~~
./Main.cpp:94:11: note: place parentheses around the '==' expression to silence this warning
                if (bin & 1 == 1) break;
                        ^
                          (     )
./Main.cpp:94:11: note: place parentheses around the & expression to evaluate it first
                if (bin & 1 == 1) break;
                        ^
                    (      )
1 warning generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 13
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt AC 9 ms 888 KB
2.txt AC 1 ms 256 KB
3.txt AC 1 ms 256 KB
4.txt AC 2 ms 256 KB
5.txt AC 1 ms 256 KB
6.txt AC 1 ms 256 KB
7.txt AC 1 ms 256 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB