QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#331953#7695. Double Upcry#WA 0ms3876kbC++20919b2024-02-19 00:39:322024-02-19 00:39:33

Judging History

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

  • [2024-02-19 00:39:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3876kb
  • [2024-02-19 00:39:32]
  • 提交

answer

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


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s;
	int n = s.size();
	for(int i = 0; i < n - 1; i++){
		if(s[i] == 'O' && s[i + 1] == 'O'){
			cout << "INVALID" << endl;
			return 0;
		}
	}
	if(s.back() != 'O'){
		cout << "INVALID" << endl;
		return 0;
	}
	for(ll start = 3; ; start += 2){
		ll res = start;
		bool ok = true;
		for(int i = n - 2; i >= 0; i--){
			if(s[i] == 'E'){
				res *= 2;
			}
			else{
				res--;
				if(res % 3 != 0){
					ok = false;
					break;
				}
				res /= 3;
			}
			if(s[i] == 'E' && res % 2 == 1){
				ok = false;
				break;
			}
			if(s[i] == 'O' && res % 2 == 0){
				ok = false;
				break;
			}
			if(__builtin_popcountll(res) == 1){
				ok = false;
				break;
			}
		}
		if(ok){
			cout << res << "\n";
			break;
		}
	}
	
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3876kb

input:

5
4 2 2 1 8

output:

INVALID

result:

wrong answer 1st lines differ - expected: '16', found: 'INVALID'