QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#588068#9378. Strange BinaryrlaaaCompile Error//C++23987b2024-09-25 00:21:552024-09-25 00:21:57

Judging History

你现在查看的是最新测评结果

  • [2024-09-25 00:21:57]
  • 评测
  • [2024-09-25 00:21:55]
  • 提交

answer

#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
vector <int> power;
int arr[32];
int main() {
	ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
	int t;    cin >> t;
	while (t--) {
		ll num,Z;
		int flag = 1;
		power.clear();
		memset(arr, -1, sizeof(arr));
		arr[31] = 1;
		cin >> num; Z = num - 1;
		if (!num) flag = 0;
		for (ll i = 1, j = 0; i <=Z; j++,i=1<<j) 
			if (Z & i) power.push_back(j);
		reverse(power.begin(), power.end());
		for (int i = 0; i < power.size()&& flag; i++) {
			if (power[i] == 0 && arr[0] != -1) flag = 0;
			if (i + 1 < power.size() && power[i] - power[i + 1] == 1) arr[power[i] - 1] = 1;
			else if (arr[power[i]] != -1) arr[power[i] - 1] = 1;
			else arr[power[i]] = 0;
		}
		if (flag) {
			cout << "YES\n";
			for (int i = 0; i < 32; i++) 
				if ((i + 1) % 8 == 0) cout << arr[i] << "\n";
				else cout << arr[i] << " ";
		}
		else cout << "NO\n";
	}
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:21:17: error: ‘reverse’ was not declared in this scope
   21 |                 reverse(power.begin(), power.end());
      |                 ^~~~~~~