PROBLEM 20
Easy

Three-Flag Access Rule

Programming Basics · Java

</>
STATUS Not solved

TASK

Problem

#20

Read three integers `admin`, `verified`, `blocked`, each 0 or 1. Print `ALLOW` if the user is not blocked and is either admin or verified; otherwise print `DENY`.

EXAMPLE

Example

Input
1 0 0
Output
ALLOW

LIMITS

Constraints

admin, verified, blocked ∈ {0,1}
📖
LEARN Theory for this problem
+

The core idea of **Three-Flag Access Rule** is to model the requested operation directly: Read three integers `admin`, `verified`, `blocked`, each 0 or 1. Print `ALLOW` if the user is not blocked and is either admin or verified; otherwise print `DENY`. The reference solution uses `Scanner` for input. Keep only the state needed for this result, choose numeric types that cover the stated bounds, and preserve the exact input/output contract. This makes the solution easier to verify on boundary cases and avoids unrelated work.

💡
NEED HELP? Hints
+

['Follow the statement for **Three-Flag Access Rule** literally and identify the smallest state needed to produce its output.', 'The reference solution relies on `Scanner` for input; test the smallest allowed input and one boundary case from the constraints.']

ANSWER Solution
+
// CodeMaster — Three-Flag Access Rule
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int admin = sc.nextInt();
        int verified = sc.nextInt();
        int blocked = sc.nextInt();
        boolean allow = blocked == 0 && (admin == 1 || verified == 1);
        System.out.println(allow ? "ALLOW" : "DENY");
    }
}