Solve Problems
Without Limits

Mirror Codeforces problems instantly. Code, test, and submit — all in one beautiful interface that works everywhere.

Supports: contest, gym, group, problemset, and ACM SGURU URLs

A. Kill Two Birds with One Stone
verdict.run/gym/106259/problem/A
A.Kill Two Birds with One Stone

Problem Statement

Why are lots of things in twos? Hands on clocks, and gloves, and shoes, Scissor-blades, and water taps, Collar studs, and luggage straps...

You are given a binary matrix M of size n × m, where rows are numbered from 1 to n from top to bottom and columns are numbered from 1 to m from left to right.

Your task is to determine whether it is possible to transform the matrix into a null matrix (i.e., a matrix where all entries are 0).

INPUT

The first line contains t (1 ≤ t ≤ 104) — the number of test cases.

OUTPUT

For each test case, output YES if possible, NO otherwise.

Features

Everything you need to solve competitive programming problems.

GNU C++20 (64)
Run TestsSubmit
1#include <bits/stdc++.h>
2using namespace std;
3 
4void solve() {
5 int n; cin >> n;
6 vector<int> a(n);
7 for (auto& x : a) cin >> x;
8 sort(a.begin(), a.end());
9 cout << a[0] << '\n';
10}
11 
12int main() {
13 int t; cin >> t;
14 while (t--) solve();
15}
Ask AI

Editor

Full-featured code editor

Monaco-powered editor with syntax highlighting for 8 languages — C++, Python, Java, Go, Rust, Kotlin, C#, and Node.js. Dual tabs for your code and AI-generated solutions.

AI TutorGuided learning mode
Teach Me

How do I solve this problem? I'm stuck on the greedy approach.

Great question! Let's think about this step by step.

Hint 1: Consider sorting the array first. What property does the sorted array give you?

Key insight: After sorting, the minimum difference between any two elements must be between adjacent elements.

C++@ lines 5-8
sort(a.begin(), a.end());
EasyMediumHard

AI Tutor

Learn, don't just copy

An AI tutor that teaches you the approach step-by-step with hints, concept explanations, and guided solutions at 3 difficulty levels — not just raw answers.

Testcase
Test ResultCodeforces
Case 1Case 2Case 3
Input
3
5 2 8 1 4
3 3 7
Expected Output
1
3
3
All test cases passed 46ms

Testing

Run tests instantly

Test against sample cases or add your own custom test cases. See input, expected output, and actual output side-by-side with verdict highlighting.

V
Verdict.run
v1.0.3
Codeforces Account
Y
YUST777
Connected
Refresh
Open App
V
Chrome Extension

Extension

One-click submit to Codeforces

Install the Verdict Helper Chrome extension. Submit code directly to Codeforces from verdict.run — no copy-paste, no tab switching. Uses your existing CF session securely.

Simple, Transparent Pricing

Start solving for free. Upgrade when you need the full competitive edge.

Free

$0 / mo

For casual competitive programmers

Get Started
  • Mirror Codeforces Problems
  • Monaco Code Editor (8 Languages)
  • Basic Test Runner
  • Submit to Codeforces
  • Community Support

Pro

$9 / mo

For serious competitors

Everything in Free plus :
  • AI Tutor (Guided Learning)
  • AI-Generated Solutions
  • Advanced Analytics & Insights
  • Runtime & Memory Distributions
  • Custom Test Case Builder
  • Submission History & Tracking
  • Priority Support
  • Early Access to New Features

Frequently Asked Questions

Everything you need to know about Verdict.run.