QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#300871#7962. 前缀和defyers#WA 0ms3616kbC++201.6kb2024-01-08 22:36:422024-01-08 22:36:43

Judging History

This is the latest submission verdict.

  • [2024-01-08 22:36:43]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3616kb
  • [2024-01-08 22:36:42]
  • Submitted

answer

#include "bits/stdc++.h"
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

using ll = long long;
using LL = long long;

const int N = 524288;

int qid = 0;
struct query{
	int t, x, y;
};

vector<query> ans;
int make(int ty, int x, int y = 0){
	if(ty == 2){
		if(x == 0 || y == 0){
			return x + y;
		}
	}
	if(ty == 3 && x == 0) return 0;
	ans.push_back({ty, x + (ty == 1), y});
	return ++qid;
}

bool in[N];
int construct(int shift, int sz, vector<int> A){
	if(A.size() == 0){
		return 0;
	}
	if(A.size() == 1){
		return make(1, A[0]);
	}

	int half = sz / 2;
	for(auto x : A) in[x] = true;
	vector<int> A0, A1, A2;
	for(int i = shift; i < shift + half; i++){
		if(in[i] && in[i ^ half]) A2.push_back(i);
		if(in[i] && !in[i ^ half]) A0.push_back(i);
		if(!in[i] && in[i ^ half]) A1.push_back(i ^ half);
	}
	int a = construct(shift, half, A0);
	int b = construct(shift, half, A1);
	int c = construct(shift, half, A2);
	int d = make(3, c, half);

	int ac = make(2, a, c);
	int bd = make(2, b, d);
	int abcd = make(2, ac, bd);
	return abcd;
}

void solve(int TC) {
	int n; cin >> n;
	string s; cin >> s;
	vector<int> A;
	for(int i = 0; i < n; i++){
		if(s[i] == '1'){
			A.push_back(i);
		}
	}
	construct(0, N, A);
	cout << ans.size() << '\n';
	for(auto [t, x, y] : ans){
		cout << t << ' ' << x;
		if(t != 1) cout << ' ' << y;
		cout << '\n';
	}
}

int32_t main() {
	cin.tie(0)->sync_with_stdio(0);
	cout << fixed << setprecision(10);

	int t = 1;
	// cin >> t;

	for (int i = 1; i <= t; i++) {
		solve(i);
	}
}

詳細信息

Test #1:

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

input:

3 0.5 1 2

output:

0

result:

wrong answer 1st numbers differ - expected: '1.0000000', found: '0.0000000', error = '1.0000000'