oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

queens Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

queens.html

Problem Description

Given an N x N chessboard, and several queens placed on it, determine if any pair of queens attack each other.

One queen is said to attack another if the attacked queen shares the same row, column or diagonal as the attacker, and there are no queens in between them.

Limits

Subtask 1 (15%): 1 ≤ N ≤ 50.

Subtask 2 (20%): 1 ≤ N ≤ 300.

Subtask 3 (30%): 1 ≤ N ≤ 2000, there are at most 2 queens on the board.

Subtask 4 (35%): 1 ≤ N ≤ 2000.

Subtask 5 (0%): Sample Testcases.

Input

The first line of input will contain one integer, N.

The next N lines of input will contain N characters each, with each character being either '.' (an empty square) or 'Q' (a queen), describing the grid.

Output

The output should contain either "Attack" or "No Attack", depending on whether there exists two queens attacking one another.

Sample Testcase 1

Input

4
Q...
..Q.
.Q..
...Q

Output

Attack

Sample Testcase 2

Input

8
...Q....
......Q.
..Q.....
.......Q
.Q......
....Q...
Q.......
.....Q..

Output

No Attack

Tags

Syntax

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
115221s256MBMinimum
220421s256MBMinimum
330201s256MBMinimum
435821s256MBMinimum
5021s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o queens -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.