The following languages are only available languages for the problems from the contest

Microsoft Q# Coding Contest - Summer 2018 - Warmup:

- Microsoft Q#

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

I. Deutsch-Jozsa algorithm

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given a quantum oracle - an operation on *N* + 1 qubits which implements a function . You are guaranteed that the function *f* implemented by the oracle is either constant (returns 0 on all inputs or 1 on all inputs) or balanced (returns 0 on exactly one half of the input domain and 1 on the other half).

There are only two possible constant functions: *f*(*x*) = 0 and *f*(*x*) = 1. The functions implemented by oracles in the two previous problems (*f*(*x*) = *x*_{k} and ) are examples of balanced functions.

Your task is to figure out whether the function given by the oracle is constant. Your code is allowed to call the given oracle only once.

Input

You have to implement an operation which takes the following inputs:

- an integer
*N*- the number of qubits in the oracle input, - an oracle
*Uf*, implemented as an operation with signature ((Qubit[], Qubit) => ()), i.e., an operation which takes as input an array of qubits and an output qubit and has no output.

The return of your operation is a Boolean value: true if the oracle implements a constant function and false otherwise.

Your code should have the following signature:

namespace Solution {

open Microsoft.Quantum.Primitive;

open Microsoft.Quantum.Canon;

operation Solve (N : Int, Uf : ((Qubit[], Qubit) => ())) : Bool

{

body

{

// your code here

}

}

}

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/19/2018 11:03:41 (d1).

Desktop version, switch to mobile version.

User lists

Name |
---|