buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace MyProject {
class Program {
static void Main(string[] args) {
#if Local
var sw = new Stopwatch();
sw.Start();
Console.SetIn(new StreamReader("input.in"));
#endif
var solver = new Solver();
solver.Solve();
#if Local
Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
}
}
class Solver {
public void Solve() {
var N = int.Parse(Console.ReadLine());
var X =
Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
int answer = int.MaxValue;
foreach (var P in Enumerable.Range(1, N)) {
int sum = 0;
foreach (var i in Enumerable.Range(0, N)) {
sum += (int)Math.Pow(X[i] - P, 2);
}
if (sum <= answer) {
answer = sum;
}
}
Console.WriteLine(answer);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace MyProject {
class Program {
static void Main(string[] args) {
#if Local
var sw = new Stopwatch();
sw.Start();
Console.SetIn(new StreamReader("input.in"));
#endif
var solver = new Solver();
solver.Solve();
#if Local
Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
}
}
class Solver {
public void Solve() {
var N = int.Parse(Console.ReadLine());
var X =
Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
int answer = int.MaxValue;
foreach (var P in Enumerable.Range(1, 100)) {
int sum = 0;
foreach (var i in Enumerable.Range(0, N)) {
sum += (int)Math.Pow(X[i] - P, 2);
}
if (sum <= answer) {
answer = sum;
}
}
Console.WriteLine(answer);
}
}
}
|
[["-", 0, 210, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 210, 12, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 245
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace PaizaTest {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
// var sumList = new int[n + 1];
// (x - p)^2 分体力を消費する
// 累積和の計算を行う
var nList = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
var maxDistance = nList.Max();
int maxPower = int.MaxValue;
// int maxIndex = 0;
for (int i = 0; i < maxDistance; i++) {
var meetingIndex = i;
var currentPower = 0;
for (int j = 0; j < nList.Count; j++) {
currentPower += (nList[j] - meetingIndex) * (nList[j] - meetingIndex);
}
if (maxPower > currentPower) {
maxPower = currentPower;
// maxIndex = i;
}
}
Console.WriteLine(maxPower);
// Console.WriteLine($"index: {maxIndex}");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace PaizaTest {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
// var sumList = new int[n + 1];
// (x - p)^2 分体力を消費する
// 累積和の計算を行う
var nList = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
var maxDistance = nList.Max();
int maxPower = int.MaxValue;
// int maxIndex = 0;
for (int i = 1; i <= maxDistance; i++) {
var meetingIndex = i;
var currentPower = 0;
for (int j = 0; j < nList.Count; j++) {
currentPower += (nList[j] - meetingIndex) * (nList[j] - meetingIndex);
}
if (maxPower > currentPower) {
maxPower = currentPower;
// maxIndex = i;
}
}
Console.WriteLine(maxPower);
// Console.WriteLine($"index: {maxIndex}");
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 180
| 4
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
// 入力
string[] st = Console.ReadLine().Split(' ');
long[] ab = Console.ReadLine().Split().Select(long.Parse).ToArray();
var u = Console.ReadLine();
long ans = 0;
if (u == st[0]) {
ab[0] -= 1;
}
if (u == st[1]) {
ab[1] -= 1;
}
Console.WriteLine(ab[0] + "," + ab[1]);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
// 入力
string[] st = Console.ReadLine().Split(' ');
long[] ab = Console.ReadLine().Split().Select(long.Parse).ToArray();
var u = Console.ReadLine();
long ans = 0;
if (u == st[0]) {
ab[0] -= 1;
}
if (u == st[1]) {
ab[1] -= 1;
}
Console.WriteLine(ab[0] + " " + ab[1]);
}
}
|
[["-", 0, 28, 0, 16, 31, 16, 12, 5, 0, 222], ["+", 0, 28, 0, 16, 31, 16, 12, 5, 0, 222]]
| 8
| 137
| 2
|
using System;
class sample {
static void Main() {
string input = Console.ReadLine();
string output = "";
for (int i = 0; i < input.Length; i++) {
output += "×";
}
Console.WriteLine(output);
}
}
|
using System;
class sample {
static void Main() {
string input = Console.ReadLine();
string output = "";
for (int i = 0; i < input.Length; i++) {
output += "x";
}
Console.WriteLine(output);
}
}
|
[["-", 8, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 8, 196, 0, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 60
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace abc088b {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
int num = s.Length;
string ans = "";
var temp = Enumerable.Repeat("×", num).ToList();
foreach (var item in temp) {
ans += item;
}
Console.Write(ans);
}
}
}
|
/*
int n = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToList();
*/
using System;
using System.Linq;
using System.Collections.Generic;
namespace abc088b {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
int num = s.Length;
string ans = "";
var temp = Enumerable.Repeat("x", num).ToList();
foreach (var item in temp) {
ans += item;
}
Console.Write(ans);
}
}
}
/*
var s = Console.ReadLine().Split().ToArray();
var a = Console.ReadLine().Split().Select(b => int.Parse(b)).ToArray();
var u = Console.ReadLine();
if(s.All(name => name == u))
{
Console.WriteLine(a[0]);
Console.WriteLine(a[1]);
}
else
{
if (u == s[0])
{
a[0] = a[0] - 1;
Console.Write($"{a[0]} {a[1]}");
}
else
{
a[1] = a[1] - 1;
Console.Write($"{a[0]} {a[1]}");
}
}
}
*/
|
[["-", 205, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 205, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 94
| 2
|
using System;
using System.Linq;
namespace ConsoleApp1111 {
class Program {
static void Main(string[] args) {
var s = int.Parse(Console.ReadLine().Trim());
Console.WriteLine(new string('x', s));
}
}
}
|
using System;
using System.Linq;
namespace ConsoleApp1111 {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine().Trim().Length;
Console.WriteLine(new string('x', s));
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22]]
| 8
| 60
| 7
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class ProgramC {
static void Main(string[] args) {
var a = long.Parse(Console.ReadLine());
var list =
Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();
var list2 = list.Distinct().ToList();
Console.WriteLine(list.Count == list2.Count ? "Yes" : "No");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class ProgramC {
static void Main(string[] args) {
var a = long.Parse(Console.ReadLine());
var list =
Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();
var list2 = list.Distinct().ToList();
Console.WriteLine(list.Count == list2.Count ? "YES" : "NO");
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 114
| 4
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var A = cin.ReadLine.Split(' ').Select(x => int.Parse(x));
var counts = A.GroupBy(x => x).Select(x => x.Count());
var ans = true;
foreach (var count in counts) {
if (count > 1) {
ans = false;
break;
}
}
WriteLine(ans ? "Yes" : "No");
}
public void Display(char[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item;
}
WriteLine("{0}", txt);
}
public void Display(int[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item.ToString();
}
WriteLine("{0}", txt);
}
public void Display(int index, int[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item.ToString();
}
WriteLine("{0} : {1}", index, txt);
}
public void Display(List<int>[] list) {
for (int i = 0; i < list.Length; i++) {
Display(i, list[i].ToArray());
}
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; i++)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
struct ModInt {
const int M = 1000000007;
public long V;
public ModInt(long v) { V = (v %= M) < 0 ? v + M : v; }
public static implicit operator ModInt(long v) => new ModInt(v);
public static ModInt operator +(ModInt x) => x;
public static ModInt operator -(ModInt x) => -x.V;
public static ModInt operator +(ModInt x, ModInt y) => x.V + y.V;
public static ModInt operator -(ModInt x, ModInt y) => x.V - y.V;
public static ModInt operator *(ModInt x, ModInt y) => x.V * y.V;
public static ModInt operator /(ModInt x, ModInt y) => x.V * y.Inv();
public ModInt Pow(int i) => MPow(V, i);
public ModInt Inv() => MPow(V, M - 2);
public override string ToString() => $"{V}";
static long MPow(long b, int i) {
for (var r = 1L;; b = b * b % M) {
if (i % 2 > 0)
r = r * b % M;
if ((i /= 2) < 1)
return r;
}
}
public static long MFactorial(int n) {
for (long x = 1, i = 1;; x = x * ++i % M)
if (i >= n)
return x;
}
public static long MNpr(int n, int r) {
if (n < r)
return 0;
for (long x = 1, i = n - r;; x = x * ++i % M)
if (i >= n)
return x;
}
public static ModInt MNcr(int n, int r) => n < r ? 0
: n - r < r ? MNcr(n, n - r)
: (ModInt)MNpr(n, r) /
MFactorial(r);
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var A = cin.ReadLine.Split(' ').Select(x => int.Parse(x));
var counts = A.GroupBy(x => x).Select(x => x.Count());
var ans = true;
foreach (var count in counts) {
if (count > 1) {
ans = false;
break;
}
}
WriteLine(ans ? "YES" : "NO");
}
public void Display(char[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item;
}
WriteLine("{0}", txt);
}
public void Display(int[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item.ToString();
}
WriteLine("{0}", txt);
}
public void Display(int index, int[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item.ToString();
}
WriteLine("{0} : {1}", index, txt);
}
public void Display(List<int>[] list) {
for (int i = 0; i < list.Length; i++) {
Display(i, list[i].ToArray());
}
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; i++)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
struct ModInt {
const int M = 1000000007;
public long V;
public ModInt(long v) { V = (v %= M) < 0 ? v + M : v; }
public static implicit operator ModInt(long v) => new ModInt(v);
public static ModInt operator +(ModInt x) => x;
public static ModInt operator -(ModInt x) => -x.V;
public static ModInt operator +(ModInt x, ModInt y) => x.V + y.V;
public static ModInt operator -(ModInt x, ModInt y) => x.V - y.V;
public static ModInt operator *(ModInt x, ModInt y) => x.V * y.V;
public static ModInt operator /(ModInt x, ModInt y) => x.V * y.Inv();
public ModInt Pow(int i) => MPow(V, i);
public ModInt Inv() => MPow(V, M - 2);
public override string ToString() => $"{V}";
static long MPow(long b, int i) {
for (var r = 1L;; b = b * b % M) {
if (i % 2 > 0)
r = r * b % M;
if ((i /= 2) < 1)
return r;
}
}
public static long MFactorial(int n) {
for (long x = 1, i = 1;; x = x * ++i % M)
if (i >= n)
return x;
}
public static long MNpr(int n, int r) {
if (n < r)
return 0;
for (long x = 1, i = n - r;; x = x * ++i % M)
if (i >= n)
return x;
}
public static ModInt MNcr(int n, int r) => n < r ? 0
: n - r < r ? MNcr(n, n - r)
: (ModInt)MNpr(n, r) /
MFactorial(r);
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 1,120
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace atcoder {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
Console.WriteLine(n == Console.ReadLine()
.Split(' ')
.Select(num => int.Parse(num))
.Distinct()
.Count()
? "Yes"
: "NO");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace atcoder {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
Console.WriteLine(n == Console.ReadLine()
.Split(' ')
.Select(num => int.Parse(num))
.Distinct()
.Count()
? "YES"
: "NO");
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222]]
| 8
| 101
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] array =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
HashSet<int> hsTable = new HashSet<int>();
string message = "Yes";
foreach (int i in array) {
if (!hsTable.Add(i)) {
message = "No";
}
}
Console.WriteLine(message);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] array =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
HashSet<int> hsTable = new HashSet<int>();
string message = "YES";
foreach (int i in array) {
if (!hsTable.Add(i)) {
message = "NO";
}
}
Console.WriteLine(message);
}
}
}
// 24579 = hon
// 0168 = pon
// 3 = bon
// long n = long.Parse(Console.ReadLine());
// long[] inputLongArray = Console.ReadLine().Split(' ').Select(i =>
// long.Parse(i)).ToArray();
// Console.WriteLine(cnt);
// Console.ReadKey();
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 137
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
var num = int.Parse(ReadLine());
var input = ReadLine().Split(' ').GroupBy(a => a).ToArray().Length;
if (num == input) {
Write("Yes");
} else {
Write("No");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
var num = int.Parse(ReadLine());
var num2 = ReadLine().Split(' ').GroupBy(a => a).ToArray().Length;
if (num == num2) {
Write("YES");
} else {
Write("NO");
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 96
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
class Ho {
static void Main() {
var N = int.Parse(Console.ReadLine());
var azen = Console.ReadLine().Split();
var aho = azen.Distinct().ToList().Count;
var a = azen.Length;
if (a == aho) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Ho {
static void Main() {
var N = int.Parse(Console.ReadLine());
var azen = Console.ReadLine().Split();
var aho = azen.Distinct().ToList().Count;
var a = azen.Length;
if (a == aho) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 104
| 4
|
using System;
using System.Linq;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
Console.ReadLine();
var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(A.Distinct().Count() == A.Length ? "Yes" : "No");
}
}
}
|
using System;
using System.Linq;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
Console.ReadLine();
var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(A.Distinct().Count() == A.Length ? "YES" : "NO");
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 84
| 4
|
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;
class MainClass {
public static void Main(string[] args) {
var N = LnInt();
var hash = new HashSet<long>(LnLngs());
print(N == hash.Count ? "Yes" : "No");
}
public static long SumAtoB(long a, long b) {
var length = b - a + 1;
return (a + b) * (length / 2) + (length % 2 == 1 ? (a + b) / 2 : 0);
}
public static long PowLite(long n, long p, int mod = (int)1e9 + 7) {
long ans = 1;
long now = n;
for (; p > 0; p >>= 1) {
if ((p & 1) == 1) {
ans *= now;
ans %= mod;
}
now *= now;
now %= mod;
}
return ans;
}
public static void print(object obj) { Console.WriteLine(obj); }
public static long Gcd(long a, long b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int Gcd(int a, int b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int[] LnInts() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new int[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = int.Parse(vs[i]);
return ins;
}
public static int LnInt() {
var vs = Console.ReadLine().Trim();
return int.Parse(vs);
}
public static long[] LnLngs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new long[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = long.Parse(vs[i]);
return ins;
}
public static long LnLng() {
var vs = Console.ReadLine().Trim();
return long.Parse(vs);
}
public static string[] LnStrs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
return vs;
}
public static string LnStr() {
var vs = Console.ReadLine().Trim();
return vs;
}
public static List<T[]> AllPermutation<T>(params T[] array)
where T : IComparable {
var a = new List<T>(array).ToArray();
var res = new List<T[]>();
res.Add(new List<T>(a).ToArray());
var n = a.Length;
var next = true;
while (next) {
next = false;
int i;
for (i = n - 2; i >= 0; i--) {
if (a[i].CompareTo(a[i + 1]) < 0)
break;
}
if (i < 0)
break;
var j = n;
do {
j--;
} while (a[i].CompareTo(a[j]) > 0);
if (a[i].CompareTo(a[j]) < 0) {
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
Array.Reverse(a, i + 1, n - i - 1);
res.Add(new List<T>(a).ToArray());
next = true;
}
}
return res;
}
}
|
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;
class MainClass {
public static void Main(string[] args) {
var N = LnInt();
var hash = new HashSet<long>(LnLngs());
print(N == hash.Count ? "YES" : "NO");
}
public static long SumAtoB(long a, long b) {
var length = b - a + 1;
return (a + b) * (length / 2) + (length % 2 == 1 ? (a + b) / 2 : 0);
}
public static long PowLite(long n, long p, int mod = (int)1e9 + 7) {
long ans = 1;
long now = n;
for (; p > 0; p >>= 1) {
if ((p & 1) == 1) {
ans *= now;
ans %= mod;
}
now *= now;
now %= mod;
}
return ans;
}
public static void print(object obj) { Console.WriteLine(obj); }
public static long Gcd(long a, long b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int Gcd(int a, int b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int[] LnInts() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new int[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = int.Parse(vs[i]);
return ins;
}
public static int LnInt() {
var vs = Console.ReadLine().Trim();
return int.Parse(vs);
}
public static long[] LnLngs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new long[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = long.Parse(vs[i]);
return ins;
}
public static long LnLng() {
var vs = Console.ReadLine().Trim();
return long.Parse(vs);
}
public static string[] LnStrs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
return vs;
}
public static string LnStr() {
var vs = Console.ReadLine().Trim();
return vs;
}
public static List<T[]> AllPermutation<T>(params T[] array)
where T : IComparable {
var a = new List<T>(array).ToArray();
var res = new List<T[]>();
res.Add(new List<T>(a).ToArray());
var n = a.Length;
var next = true;
while (next) {
next = false;
int i;
for (i = n - 2; i >= 0; i--) {
if (a[i].CompareTo(a[i + 1]) < 0)
break;
}
if (i < 0)
break;
var j = n;
do {
j--;
} while (a[i].CompareTo(a[j]) > 0);
if (a[i].CompareTo(a[j]) < 0) {
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
Array.Reverse(a, i + 1, n - i - 1);
res.Add(new List<T>(a).ToArray());
next = true;
}
}
return res;
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 930
| 4
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace A {
class StartingPoint {
static void Main(string[] args) {
if (args?.Any() == true) {
var assembly = Assembly.GetEntryAssembly();
var path = "../../../../In.txt";
var stream = new FileStream(path, FileMode.Open);
var streamReader = new StreamReader(stream, Encoding.UTF8);
var str = streamReader.ReadToEnd();
var textReader = new StringReader(str);
Console.SetIn(textReader);
}
try {
foreach (var s in new Program().Solve()) {
Console.WriteLine(s);
}
} catch (Exception e) {
Console.WriteLine(e);
if (args?.Any() != true)
throw e;
}
if (args?.Any() == true)
Console.ReadKey();
}
}
class Program {
public List<int> ScanInts(int count) =>
Enumerable.Range(0, count).Select(_ => ScanInt).ToList();
public List<int> ScanInts(long count) => ScanInts((int)count);
public List<long>
ScanLongs(int count) => Enumerable.Range(0, count).Select(_ => Scan).ToList();
public List<long> ScanLongs(long count) => ScanLongs((int)count);
public int ScanInt => int.Parse(Str);
public long Scan => long.Parse(Str);
public double ScanDouble => (double)Scan;
StringBuilder sb = new StringBuilder();
public string Str => ScanStr();
public string ScanStr() {
sb.Clear();
int r = 0;
bool? b = null;
do {
r = Console.Read();
b = IsBreak(r);
} while (b == true);
if (b == null)
throw new Exception("input error: unexpected end of stream");
do {
sb.Append((char)r);
r = Console.Read();
b = IsBreak(r);
} while (b == false);
return sb.ToString();
}
bool? IsBreak(int c) {
switch (c) {
case -1:
return null;
case (int)' ':
case (int)'\n':
case (int)'\r':
return true;
default:
return false;
}
}
public IEnumerable<int> Loop(int count) => Enumerable.Range(0, count);
public IEnumerable<int> Loop(int from,
int to) => Enumerable.Range(from, to - from + 1);
public IEnumerable<long> Loop(long count) => Loop(0, count - 1);
public IEnumerable<long> Loop(long from, long to) {
for (long i = from; i <= to; i++)
yield return i;
}
public string YesNo(bool isYes) => isYes ? "Yes" : "No";
public HashSet<T> ToHashSet<T>(IEnumerable<T> ts) => new HashSet<T>(ts);
public IEnumerable<string> Solve() {
var n = Scan;
var a = ScanInts(n);
yield return YesNo(a.GroupBy(x => x).Any(x => x.Count() > 1) == false);
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace A {
class StartingPoint {
static void Main(string[] args) {
if (args?.Any() == true) {
var assembly = Assembly.GetEntryAssembly();
var path = "../../../../In.txt";
var stream = new FileStream(path, FileMode.Open);
var streamReader = new StreamReader(stream, Encoding.UTF8);
var str = streamReader.ReadToEnd();
var textReader = new StringReader(str);
Console.SetIn(textReader);
}
try {
foreach (var s in new Program().Solve()) {
Console.WriteLine(s);
}
} catch (Exception e) {
Console.WriteLine(e);
if (args?.Any() != true)
throw e;
}
if (args?.Any() == true)
Console.ReadKey();
}
}
class Program {
public List<int> ScanInts(int count) =>
Enumerable.Range(0, count).Select(_ => ScanInt).ToList();
public List<int> ScanInts(long count) => ScanInts((int)count);
public List<long>
ScanLongs(int count) => Enumerable.Range(0, count).Select(_ => Scan).ToList();
public List<long> ScanLongs(long count) => ScanLongs((int)count);
public int ScanInt => int.Parse(Str);
public long Scan => long.Parse(Str);
public double ScanDouble => (double)Scan;
StringBuilder sb = new StringBuilder();
public string Str => ScanStr();
public string ScanStr() {
sb.Clear();
int r = 0;
bool? b = null;
do {
r = Console.Read();
b = IsBreak(r);
} while (b == true);
if (b == null)
throw new Exception("input error: unexpected end of stream");
do {
sb.Append((char)r);
r = Console.Read();
b = IsBreak(r);
} while (b == false);
return sb.ToString();
}
bool? IsBreak(int c) {
switch (c) {
case -1:
return null;
case (int)' ':
case (int)'\n':
case (int)'\r':
return true;
default:
return false;
}
}
public IEnumerable<int> Loop(int count) => Enumerable.Range(0, count);
public IEnumerable<int> Loop(int from,
int to) => Enumerable.Range(from, to - from + 1);
public IEnumerable<long> Loop(long count) => Loop(0, count - 1);
public IEnumerable<long> Loop(long from, long to) {
for (long i = from; i <= to; i++)
yield return i;
}
public string YesNo(bool isYes) => isYes ? "YES" : "NO";
public HashSet<T> ToHashSet<T>(IEnumerable<T> ts) => new HashSet<T>(ts);
public IEnumerable<string> Solve() {
var n = Scan;
var a = ScanInts(n);
yield return YesNo(a.GroupBy(x => x).Any(x => x.Count() > 1) == false);
}
}
}
|
[["-", 0, 195, 8, 306, 0, 41, 64, 5, 0, 222], ["+", 0, 195, 8, 306, 0, 41, 64, 5, 0, 222], ["-", 0, 195, 8, 306, 0, 41, 75, 5, 0, 222], ["+", 0, 195, 8, 306, 0, 41, 75, 5, 0, 222]]
| 8
| 707
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoders {
class Program {
static void Main(string[] args) {
var inputArray = retreiveLongArray();
var inputCount = 1;
// 不正な入力は処理しない
if (inputArray.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
var N = inputArray[0];
var numArray = retreiveLongArray();
// Keyと、登場回数
var dictionary = new Dictionary<long, int>();
foreach (var n in numArray) {
if (dictionary.ContainsKey(n)) {
dictionary[n] += 1;
} else {
dictionary.Add(n, 1);
}
}
//答えの出力
if (dictionary.All(x => x.Value == 1)) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
/// <summary>
/// スペースで区切られた文字列配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static string[] retreiveStringArray() {
var inputArray = Console.ReadLine().Split(' ');
return inputArray;
}
/// <summary>
/// スペースで区切られた整数配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static long[] retreiveLongArray() {
var inputArray = Console.ReadLine().Split(' ');
var longArray = inputArray.Select(s => long.Parse(s));
return longArray.ToArray();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoders {
class Program {
static void Main(string[] args) {
var inputArray = retreiveLongArray();
var inputCount = 1;
// 不正な入力は処理しない
if (inputArray.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
var N = inputArray[0];
var numArray = retreiveLongArray();
// Keyと、登場回数
var dictionary = new Dictionary<long, int>();
foreach (var n in numArray) {
if (dictionary.ContainsKey(n)) {
dictionary[n] += 1;
} else {
dictionary.Add(n, 1);
}
}
//答えの出力
if (dictionary.All(x => x.Value == 1)) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
/// <summary>
/// スペースで区切られた文字列配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static string[] retreiveStringArray() {
var inputArray = Console.ReadLine().Split(' ');
return inputArray;
}
/// <summary>
/// スペースで区切られた整数配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static long[] retreiveLongArray() {
var inputArray = Console.ReadLine().Split(' ');
var longArray = inputArray.Select(s => long.Parse(s));
return longArray.ToArray();
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 274
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace IMissYou {
class Program {
static void Main(string[] args) {
string inputNumbers = Console.ReadLine();
long inputNum = Convert.ToInt64(inputNumbers);
var input = Console.ReadLine().Split(' ');
List<long> inputs = new List<long>();
for (int i = 0; i < inputNum; i++) {
inputs.Add(Convert.ToInt64(input[i]));
}
var distinctNumbers = inputs.Distinct();
if (distinctNumbers.Count() == inputs.Count()) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace IMissYou {
class Program {
static void Main(string[] args) {
string inputNumbers = Console.ReadLine();
long inputNum = Convert.ToInt64(inputNumbers);
var input = Console.ReadLine().Split(' ');
List<long> inputs = new List<long>();
for (int i = 0; i < inputNum; i++) {
inputs.Add(Convert.ToInt64(input[i]));
}
var distinctNumbers = inputs.Distinct();
if (distinctNumbers.Count() == inputs.Count()) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 160
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static int digit(long x) {
int d = 0;
if (x == 0)
return 1;
else {
while (x > 0) {
x /= 10;
d++;
}
return d;
}
}
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
var input = Reads();
var a = new long[n];
for (long i = 0; i < n; i++) {
a[i] = input[i];
}
Array.Sort(a);
bool f = false;
for (long i = 0; i < n - 1; i++) {
if (a[i] == a[i + 1]) {
f = true;
}
}
if (f)
Console.WriteLine("No");
else
Console.WriteLine("Yes");
Console.Out.Flush();
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static int digit(long x) {
int d = 0;
if (x == 0)
return 1;
else {
while (x > 0) {
x /= 10;
d++;
}
return d;
}
}
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
var input = Reads();
var a = new long[n];
for (long i = 0; i < n; i++) {
a[i] = input[i];
}
Array.Sort(a);
bool f = false;
for (long i = 0; i < n - 1; i++) {
if (a[i] == a[i + 1]) {
f = true;
}
}
if (f)
Console.WriteLine("NO");
else
Console.WriteLine("YES");
Console.Out.Flush();
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 288
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
namespace AtCoder {
class Program {
static void Main() {
var N = ReadLine();
var dic = new Dictionary<int, bool>();
foreach (var A in ReadLine().Split().Select(int.Parse)) {
bool res;
dic.TryGetValue(A, out res);
if (res) {
WriteLine("No");
return;
} else
dic.Add(A, true);
}
WriteLine("Yes");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
namespace AtCoder {
class Program {
static void Main() {
var N = ReadLine();
var dic = new Dictionary<int, bool>();
foreach (var A in ReadLine().Split().Select(int.Parse)) {
bool res;
dic.TryGetValue(A, out res);
if (res) {
WriteLine("NO");
return;
} else
dic.Add(A, true);
}
WriteLine("YES");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 123
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C___Distinct_or_Not {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Array.Sort(a);
for (int i = 0; i < n; i++) {
if (a[i] == a[i + 1]) {
Console.WriteLine("NO");
Environment.Exit(0);
}
}
Console.WriteLine("YES");
// System.Collections.ArrayList al = new
// System.Collections.ArrayList(a.Length);
// foreach (int i in a)
//{
// if (!al.Contains(i))
// {
// al.Add(i);
// }
//}
// if (a.Length == al.Count)
//{
// Console.WriteLine("YES");
//}
// else
//{
// Console.WriteLine("NO");
//}
// for(int i = 0; i < n; i++)
//{
// for(int j = i + 1; j < n; j++)
// {
// if(a[i] - a[j] == 0)
// {
// Console.WriteLine("NO");
// Console.ReadKey();
// Environment.Exit(0);
// }
// }
//}
// Console.WriteLine("YES");
// Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C___Distinct_or_Not {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Array.Sort(a);
for (int i = 0; i < n - 1; i++) {
if (a[i] == a[i + 1]) {
Console.WriteLine("NO");
Environment.Exit(0);
}
}
Console.WriteLine("YES");
}
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 179
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C___Distinct_or_Not {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Array.Sort(a);
for (int i = 0; i < n; i++) {
if (a[i] == a[i + 1]) {
Console.WriteLine("NO");
Environment.Exit(0);
}
}
Console.WriteLine("YES");
// System.Collections.ArrayList al = new
// System.Collections.ArrayList(a.Length);
// foreach (int i in a)
//{
// if (!al.Contains(i))
// {
// al.Add(i);
// }
//}
// if (a.Length == al.Count)
//{
// Console.WriteLine("YES");
//}
// else
//{
// Console.WriteLine("NO");
//}
// for(int i = 0; i < n; i++)
//{
// for(int j = i + 1; j < n; j++)
// {
// if(a[i] - a[j] == 0)
// {
// Console.WriteLine("NO");
// Console.ReadKey();
// Environment.Exit(0);
// }
// }
//}
// Console.WriteLine("YES");
// Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C___Distinct_or_Not {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Array.Sort(a);
for (int i = 0; i < n - 1; i++) {
if (a[i] == a[i + 1]) {
Console.WriteLine("NO");
Environment.Exit(0);
}
}
Console.WriteLine("YES");
// System.Collections.ArrayList al = new
// System.Collections.ArrayList(a.Length);
// foreach (int i in a)
//{
// if (!al.Contains(i))
// {
// al.Add(i);
// }
//}
// if (a.Length == al.Count)
//{
// Console.WriteLine("YES");
//}
// else
//{
// Console.WriteLine("NO");
//}
// for(int i = 0; i < n; i++)
//{
// for(int j = i + 1; j < n; j++)
// {
// if(a[i] - a[j] == 0)
// {
// Console.WriteLine("NO");
// Console.ReadKey();
// Environment.Exit(0);
// }
// }
//}
// Console.WriteLine("YES");
// Console.ReadKey();
}
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 179
| 2
|
using System;
using System.Linq;
namespace PracticeForAtCoder {
class Program {
static void Main(string[] args) {
//ここから
int n = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(' ');
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = int.Parse(str[i]);
}
a = a.OrderBy(s => s == 1).ToArray();
for (int i = 1; i < n; i++) {
if (a[i] == a[i - 1]) {
Console.WriteLine("NO");
return;
}
}
Console.WriteLine("YES");
//ここまで
}
}
}
|
using System;
using System.Linq;
namespace PracticeForAtCoder {
class Program {
static void Main(string[] args) {
//ここから
int n = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(' ');
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = int.Parse(str[i]);
}
a = a.OrderBy(s => s).ToArray();
for (int i = 1; i < n; i++) {
if (a[i] == a[i - 1]) {
Console.WriteLine("NO");
return;
}
}
Console.WriteLine("YES");
//ここまで
}
}
}
|
[["-", 3, 4, 0, 28, 0, 218, 8, 16, 17, 60], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 12, 203]]
| 8
| 172
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Hello {
class Hello {
static void Main() {
int number = int.Parse(Console.ReadLine());
var p = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var list = new List<int>();
list.AddRange(p);
list.Sort((a, b) => b - a);
for (int i = 0; i < number - 1; i++) {
if (list[i] == list[i + 1]) {
Console.Write("No");
break;
} else if (i == number - 2) {
Console.Write("Yes");
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Hello {
class Hello {
static void Main() {
int number = int.Parse(Console.ReadLine());
var p = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var list = new List<int>();
list.AddRange(p);
list.Sort((a, b) => b - a);
for (int i = 0; i < number - 1; i++) {
if (list[i] == list[i + 1]) {
Console.Write("NO");
break;
} else if (i == number - 2) {
Console.Write("YES");
}
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 172
| 4
|
using System;
using System.Linq;
namespace ABC154_C {
class MainClass {
public static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] A = Console.ReadLine()
.Trim()
.Split(' ')
.Select(a => int.Parse(a))
.ToArray();
Array.Sort(A);
for (int i = 1; i < N - 1; i++) {
if (A[i] == A[i + 1]) {
Console.WriteLine("NO");
Environment.Exit(0);
}
}
Console.WriteLine("YES");
}
}
}
|
using System;
using System.Linq;
namespace ABC154_C {
class MainClass {
public static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] A = Console.ReadLine()
.Trim()
.Split(' ')
.Select(a => int.Parse(a))
.ToArray();
Array.Sort(A);
for (int i = 0; i < N - 1; i++) {
if (A[i] == A[i + 1]) {
Console.WriteLine("NO");
Environment.Exit(0);
}
}
Console.WriteLine("YES");
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 146
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main() {
Solve();
Console.ReadKey();
}
static void Solve() {
var N = GetInt();
var A = GetIntArray();
var D = A.Distinct();
var ans = A.Count() == D.Count() ? "Yes" : "No";
Console.WriteLine(ans);
}
static public string GetStr() { return Console.ReadLine(); }
static public int GetInt() { return int.Parse(Console.ReadLine()); }
static public long GetLong() { return long.Parse(Console.ReadLine()); }
static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
static public int[] GetIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<double> GetDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteObjects<T>(IEnumerable<T> values) {
foreach (var o in values) {
Console.Write(o + " ");
}
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main() {
Solve();
Console.ReadKey();
}
static void Solve() {
var N = GetInt();
var A = GetIntArray();
var D = A.Distinct();
var ans = A.Count() == D.Count() ? "YES" : "NO";
Console.WriteLine(ans);
}
static public string GetStr() { return Console.ReadLine(); }
static public int GetInt() { return int.Parse(Console.ReadLine()); }
static public long GetLong() { return long.Parse(Console.ReadLine()); }
static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
static public int[] GetIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<double> GetDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteObjects<T>(IEnumerable<T> values) {
foreach (var o in values) {
Console.Write(o + " ");
}
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 41, 64, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 41, 64, 5, 0, 222], ["-", 0, 200, 0, 212, 0, 41, 75, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 41, 75, 5, 0, 222]]
| 8
| 647
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace AtCoderBeginnerContest152 {
class Program {
static void Main(string[] args) {
var n = Console.ReadLine();
var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
// var input = new long[]{
// 4, 1, 3, 1, 6, 26
// };
var set = new HashSet<long>();
for (var i = 0; i < input.Length; i++) {
if (set.Contains(input[i])) {
System.Console.WriteLine("No");
return;
} else {
set.Add(input[i]);
}
}
System.Console.WriteLine("Yes");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace AtCoderBeginnerContest152 {
class Program {
static void Main(string[] args) {
var n = Console.ReadLine();
var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
// var input = new long[]{
// 4, 1, 3, 1, 6, 26
// };
var set = new HashSet<long>();
for (var i = 0; i < input.Length; i++) {
if (set.Contains(input[i])) {
System.Console.WriteLine("NO");
return;
} else {
set.Add(input[i]);
}
}
System.Console.WriteLine("YES");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 150
| 4
|
using System;
using System.Linq;
class AtCoder {
public static void Main() {
// var inputs = Console.ReadLine().Trim().Split(' ');
var N = int.Parse(Console.ReadLine().Trim());
var A = Console.ReadLine()
.Trim()
.Split(' ')
.Select(x => long.Parse(x))
.ToArray();
var U = A.Distinct().ToArray();
Console.WriteLine(A.Length == U.Length ? "Yes" : "No");
}
}
|
using System;
using System.Linq;
class AtCoder {
public static void Main() {
// var inputs = Console.ReadLine().Trim().Split(' ');
var N = int.Parse(Console.ReadLine().Trim());
var A = Console.ReadLine()
.Trim()
.Split(' ')
.Select(x => long.Parse(x))
.ToArray();
var U = A.Distinct().ToArray();
Console.WriteLine(A.Length == U.Length ? "YES" : "NO");
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 109
| 4
|
using System;
namespace Kyopuro {
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(' ');
int[] num = new int[a];
int i;
bool isNG = true;
for (i = 0; i < a; i++) {
num[i] = int.Parse(str[i]);
}
Array.Sort(num);
for (i = 1; i < a; i++) {
if (num[i] == num[i - 1]) {
isNG = true;
}
}
if (isNG) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
}
}
|
using System;
namespace Kyopuro {
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(' ');
int[] num = new int[a];
int i;
bool isNG = false;
for (i = 0; i < a; i++) {
num[i] = int.Parse(str[i]);
}
Array.Sort(num);
for (i = 1; i < a; i++) {
if (num[i] == num[i - 1]) {
isNG = true;
}
}
if (isNG) {
Console.WriteLine("NO");
} else {
Console.WriteLine("YES");
}
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 172
| 6
|
using System;
class ProgramC {
static void Main(string[] args) {
//入力
int n = int.Parse(Console.ReadLine());
long[] a = new long[n];
string[] input2 = Console.ReadLine().Split(' ');
for (int i = 0; i < n; i++)
a[i] = long.Parse(input2[i]);
//小さい順にソートする
Array.Sort(a);
//小さい順に足していけばコストが少ない。k回引いた数だけ足す。
for (int i = 1; i < n - 1; i++) {
if (a[i] == a[i - 1]) {
Console.WriteLine("NO");
return;
}
}
//答え出力
Console.WriteLine("YES");
}
}
|
using System;
class ProgramC {
static void Main(string[] args) {
//入力
int n = int.Parse(Console.ReadLine());
long[] a = new long[n];
string[] input2 = Console.ReadLine().Split(' ');
for (int i = 0; i < n; i++)
a[i] = long.Parse(input2[i]);
//小さい順にソートする
Array.Sort(a);
//小さい順に足していけばコストが少ない。k回引いた数だけ足す。
for (int i = 0; i < n - 1; i++) {
if (a[i] == a[i + 1]) {
Console.WriteLine("NO");
return;
}
}
//答え出力
Console.WriteLine("YES");
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72]]
| 8
| 155
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1 {
public class ListNode {
public int val;
public ListNode next;
public ListNode(int x) { val = x; }
}
public class Class1 {
static Dictionary<Tuple<long, long>, long> dic =
new Dictionary<Tuple<long, long>, long>();
static long mod = 1000000007;
static long[] factorial = new long[100001];
static long[] invFactorial = new long[100001];
private static void calcFanctorial(long N) {
factorial[0] = 1;
for (int i = 1; i < N + 1; i++) {
factorial[i] = factorial[i - 1] * i;
factorial[i] %= mod;
}
invFactorial[N] = inv(factorial[N]);
for (int i = (int)N; i > 0; i--) {
invFactorial[i - 1] = invFactorial[i] * i % mod;
}
}
static void Main(string[] args) {
var N = ReadLong();
var AA = ReadLongArr();
HashSet<long> ss = new HashSet<long>();
for (int i = 0; i < N; i++) {
ss.Add(AA[i]);
}
if (ss.Count == N) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
private class AB {
long cost;
long point;
}
private static long nCm(long n, long m) {
if (n < m)
return 0;
return (factorial[n] * invFactorial[m] % mod) * invFactorial[n - m] % mod;
}
public static long pow(long a, long b, long mod) {
a %= mod;
if (b <= 0)
return 1;
var t = pow(a, b / 2, mod);
if ((b & 1) == 0)
return t * t % mod;
return t * t % mod * a % mod;
}
public static long Lcm(long a, long b) {
return a * b % mod * inv(Gcd(a, b)) % mod;
}
public static long Lcm(long[] a) {
List<long> vect = new List<long>();
long lcm = 1;
for (int i = 0; i < a.Count(); i++) {
var factor = a[i] / GcdVector(vect, a[i]);
vect.Add(factor);
lcm = lcm * factor % mod;
}
return lcm;
}
static long GcdVector(List<long> a, long b) {
long ma = 1;
for (int i = 0; i < a.Count; i++)
ma = ma * a[i] % b;
return Gcd(b, ma);
}
public static long Gcd(long a, long b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public static long pow(long a, long b) => pow(a, b, mod);
public static long inv(long a) => pow(a, mod - 2);
private static char[][] ReadCharMatrix(long h) {
char[][] mtx = new char [h][];
for (int i = 0; i < h; i++) {
var s = ReadString();
mtx[i] = s.ToCharArray();
}
return mtx;
}
private static int[][] CreateIntMatrix(long h, long w) {
int[][] mtx = new int [h][];
for (int i = 0; i < h; i++) {
mtx[i] = new int[w];
}
return mtx;
}
private static string ReadString() { return Console.ReadLine(); }
private static string[] ReadStringArr() {
return Console.ReadLine().Split(' ');
}
private static long ReadLong() { return long.Parse(Console.ReadLine()); }
private static long[] ReadLongArr() {
string[] s = ReadStringArr();
long[] l = new long[s.Length];
for (int i = 0; i < l.Length; i++) {
l[i] = long.Parse(s[i]);
}
return l;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1 {
public class ListNode {
public int val;
public ListNode next;
public ListNode(int x) { val = x; }
}
public class Class1 {
static Dictionary<Tuple<long, long>, long> dic =
new Dictionary<Tuple<long, long>, long>();
static long mod = 1000000007;
static long[] factorial = new long[100001];
static long[] invFactorial = new long[100001];
private static void calcFanctorial(long N) {
factorial[0] = 1;
for (int i = 1; i < N + 1; i++) {
factorial[i] = factorial[i - 1] * i;
factorial[i] %= mod;
}
invFactorial[N] = inv(factorial[N]);
for (int i = (int)N; i > 0; i--) {
invFactorial[i - 1] = invFactorial[i] * i % mod;
}
}
static void Main(string[] args) {
var N = ReadLong();
var AA = ReadLongArr();
HashSet<long> ss = new HashSet<long>();
for (int i = 0; i < N; i++) {
ss.Add(AA[i]);
}
if (ss.Count == N) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
private class AB {
long cost;
long point;
}
private static long nCm(long n, long m) {
if (n < m)
return 0;
return (factorial[n] * invFactorial[m] % mod) * invFactorial[n - m] % mod;
}
public static long pow(long a, long b, long mod) {
a %= mod;
if (b <= 0)
return 1;
var t = pow(a, b / 2, mod);
if ((b & 1) == 0)
return t * t % mod;
return t * t % mod * a % mod;
}
public static long Lcm(long a, long b) {
return a * b % mod * inv(Gcd(a, b)) % mod;
}
public static long Lcm(long[] a) {
List<long> vect = new List<long>();
long lcm = 1;
for (int i = 0; i < a.Count(); i++) {
var factor = a[i] / GcdVector(vect, a[i]);
vect.Add(factor);
lcm = lcm * factor % mod;
}
return lcm;
}
static long GcdVector(List<long> a, long b) {
long ma = 1;
for (int i = 0; i < a.Count; i++)
ma = ma * a[i] % b;
return Gcd(b, ma);
}
public static long Gcd(long a, long b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public static long pow(long a, long b) => pow(a, b, mod);
public static long inv(long a) => pow(a, mod - 2);
private static char[][] ReadCharMatrix(long h) {
char[][] mtx = new char [h][];
for (int i = 0; i < h; i++) {
var s = ReadString();
mtx[i] = s.ToCharArray();
}
return mtx;
}
private static int[][] CreateIntMatrix(long h, long w) {
int[][] mtx = new int [h][];
for (int i = 0; i < h; i++) {
mtx[i] = new int[w];
}
return mtx;
}
private static string ReadString() { return Console.ReadLine(); }
private static string[] ReadStringArr() {
return Console.ReadLine().Split(' ');
}
private static long ReadLong() { return long.Parse(Console.ReadLine()); }
private static long[] ReadLongArr() {
string[] s = ReadStringArr();
long[] l = new long[s.Length];
for (int i = 0; i < l.Length; i++) {
l[i] = long.Parse(s[i]);
}
return l;
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 970
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Solution {
public static void Main() {
var N = int.Parse(Console.ReadLine());
var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var uniq = A.Distinct().Count();
if (A.Length == uniq) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Solution {
public static void Main() {
var N = int.Parse(Console.ReadLine());
var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var uniq = A.Distinct().Count();
if (A.Length == uniq) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 113
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProgramingStudying2 {
class Program {
static void Main(string[] args) {
var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
var n = nk[0];
var k = nk[1];
var p = Console.ReadLine().Split().Select(double.Parse).ToList();
var Ep = new double[n];
for (int i = 0; i < n; i++) {
Ep[i] = (p[i] + 1) / 2;
}
var sum = 0.0;
for (int i = 0; i < k; i++) {
sum += Ep[i];
}
var ans = 0.0;
for (int i = 0; i < n - k; i++) {
sum += Ep[k + i] - Ep[i];
if (sum > ans) {
ans = sum;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProgramingStudying2 {
class Program {
static void Main(string[] args) {
var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
var n = nk[0];
var k = nk[1];
var p = Console.ReadLine().Split().Select(double.Parse).ToList();
var Ep = new double[n];
for (int i = 0; i < n; i++) {
Ep[i] = (p[i] + 1) / 2;
}
var sum = 0.0;
for (int i = 0; i < k; i++) {
sum += Ep[i];
}
var ans = sum;
for (int i = 0; i < n - k; i++) {
sum += Ep[k + i] - Ep[i];
if (sum > ans) {
ans = sum;
}
}
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 250], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22]]
| 8
| 228
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class35 {
static void Main() {
var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = NK[0], K = NK[1];
var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
double sum = 0;
double max = -1;
for (int i = 0; i < N; i++) {
sum += p[i];
if (i < K)
continue;
sum -= p[i - K];
max = Math.Max(max, sum);
}
Console.WriteLine(K + (max - K) / 2);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class35 {
static void Main() {
var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = NK[0], K = NK[1];
var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
double sum = 0;
double max = -1;
for (int i = 0; i < N; i++) {
sum += p[i];
if (i >= K)
sum -= p[i - K];
max = Math.Max(max, sum);
}
Console.WriteLine(K + (max - K) / 2);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 0, 7, 8, 196, 0, 57, 64, 116, 0, 117], ["-", 0, 7, 8, 196, 0, 57, 64, 116, 0, 35]]
| 8
| 182
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
var order = ReadLine().Split(' ').Select(int.Parse).ToArray();
var dices = ReadLine().Split(' ').Select(int.Parse).ToArray();
var num = 0;
var total = 0;
decimal evalue = 0;
for (var i = 0; i < order[1]; i++) {
num += dices[i];
}
for (var i = 0; i < order[0] - order[1]; i++) {
num = num - dices[i] + dices[order[1] + i];
if (num > total) {
total = num;
}
}
evalue = decimal.Divide(total + order[1], 2);
Write(evalue);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
var order = ReadLine().Split(' ').Select(int.Parse).ToArray();
var dices = ReadLine().Split(' ').Select(int.Parse).ToArray();
var num = 0;
var total = 0;
decimal evalue = 0;
for (var i = 0; i < order[1]; i++) {
num += dices[i];
}
total = num;
for (var i = 0; i < order[0] - order[1]; i++) {
num = num - dices[i] + dices[order[1] + i];
if (num > total) {
total = num;
}
}
evalue = decimal.Divide(total + order[1], 2);
Write(evalue);
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 199
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
var order = ReadLine().Split(' ').Select(int.Parse).ToArray();
var dice = ReadLine().Split(' ').Select(long.Parse).ToArray();
decimal num = 0;
decimal total = 0;
decimal evalue = 0;
var dice1 = dice.Select(i => i + 1).ToArray();
var dices = dice1.Select(i => decimal.Divide(i, 2)).ToArray();
for (var i = 0; i < order[1]; i++) {
num += dices[i];
}
for (var i = 0; i < order[0] - order[1]; i++) {
num = num - dices[i] + dices[order[1] + i];
if (num > total) {
total = num;
}
}
// evalue = decimal.Divide(total + order[1],2);
Write(total);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
var order = ReadLine().Split(' ').Select(int.Parse).ToArray();
var dice = ReadLine().Split(' ').Select(long.Parse).ToArray();
decimal num = 0;
decimal total = 0;
decimal evalue = 0;
var dice1 = dice.Select(i => i + 1).ToArray();
var dices = dice1.Select(i => decimal.Divide(i, 2)).ToArray();
for (var i = 0; i < order[1]; i++) {
num += dices[i];
}
total = num;
for (var i = 0; i < order[0] - order[1]; i++) {
num = num - dices[i] + dices[order[1] + i];
if (num > total) {
total = num;
}
}
// evalue = decimal.Divide(total + order[1],2);
Write(total);
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 225
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC156 {
class Program {
static void Main(string[] args) { c(); }
public static void c() {
int n = int.Parse(Console.ReadLine());
int[] x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
Array.Sort(x);
Array.Reverse(x);
int max = x[0];
// Console.Write(max);
double sum = 1000000000;
for (int i = 1; i < max; i++) {
double y = 0;
for (int j = 1; j < n + 1; j++) {
double a = Math.Pow(x[j - 1] - i, 2);
y += a;
}
// Console.WriteLine(y);
sum = Math.Min(sum, y);
// Console.WriteLine(sum);
sum = Math.Floor(sum);
}
Console.WriteLine(sum);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC156 {
class Program {
static void Main(string[] args) { c(); }
public static void c() {
int n = int.Parse(Console.ReadLine());
int[] x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
Array.Sort(x);
Array.Reverse(x);
int max = x[0];
// Console.WriteLine(max);
double sum = 1000000000;
for (int i = 1; i < max + 1; i++) {
double y = 0;
for (int j = 1; j < n + 1; j++) {
double a = Math.Pow(x[j - 1] - i, 2);
y += a;
}
// Console.WriteLine(y);
sum = Math.Min(sum, y);
// Console.WriteLine(sum);
sum = Math.Floor(sum);
}
Console.WriteLine(sum);
}
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 220
| 2
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;
class Program {
static void Main(string[] args) {
int N;
intReadLine(out N);
int[] X = intArrayReadLine();
int ans = int.MaxValue;
for (int i = 1; i < X.Max(); i++) {
int count = 0;
for (int j = 0; j < N; j++) {
count += (X[j] - i) * (X[j] - i);
}
if (count < ans) {
ans = count;
}
}
WriteLine(ans);
// ReadLine();
}
}
static class exReadLine {
public static void intReadLine(out int a) { a = int.Parse(ReadLine()); }
public static void intReadLine(out int a, out int b) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
}
public static void intReadLine(out int a, out int b, out int c) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void intReadLine(out int a, out int b, out int c, out int d) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void longReadLine(out long a) { a = long.Parse(ReadLine()); }
public static void longReadLine(out long a, out long b) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
}
public static void longReadLine(out long a, out long b, out long c) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void longReadLine(out long a, out long b, out long c,
out long d) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static int[] intArrayReadLine() {
return ReadLine().Split().Select(int.Parse).ToArray();
}
public static long[] longArrayReadLine() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
public static List<int> intListReadLine() {
return ReadLine().Split().Select(int.Parse).ToList();
}
public static List<long> longListReadLine() {
return ReadLine().Split().Select(long.Parse).ToList();
}
}
static class exMath {
// 最大公約数
public static int Gcd(int a, int b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
public static long Gcd(long a, long b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
// 最小公倍数
public static long Lcm(int a, int b) { return BigMul(a, b) / Gcd(a, b); }
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;
class Program {
static void Main(string[] args) {
int N;
intReadLine(out N);
int[] X = intArrayReadLine();
int ans = int.MaxValue;
for (int i = 1; i <= X.Max(); i++) {
int count = 0;
for (int j = 0; j < N; j++) {
count += (X[j] - i) * (X[j] - i);
}
if (count < ans) {
ans = count;
}
}
WriteLine(ans);
// ReadLine();
}
}
static class exReadLine {
public static void intReadLine(out int a) { a = int.Parse(ReadLine()); }
public static void intReadLine(out int a, out int b) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
}
public static void intReadLine(out int a, out int b, out int c) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void intReadLine(out int a, out int b, out int c, out int d) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void longReadLine(out long a) { a = long.Parse(ReadLine()); }
public static void longReadLine(out long a, out long b) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
}
public static void longReadLine(out long a, out long b, out long c) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void longReadLine(out long a, out long b, out long c,
out long d) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static int[] intArrayReadLine() {
return ReadLine().Split().Select(int.Parse).ToArray();
}
public static long[] longArrayReadLine() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
public static List<int> intListReadLine() {
return ReadLine().Split().Select(int.Parse).ToList();
}
public static List<long> longListReadLine() {
return ReadLine().Split().Select(long.Parse).ToList();
}
}
static class exMath {
// 最大公約数
public static int Gcd(int a, int b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
public static long Gcd(long a, long b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
// 最小公倍数
public static long Lcm(int a, int b) { return BigMul(a, b) / Gcd(a, b); }
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 880
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
var end = array.Max();
double min = double.MaxValue;
for (int i = 0; i < end; i++) {
double sum = 0;
for (int j = 0; j < array.Length; j++) {
sum += Math.Pow((array[j] - i), 2);
}
if (sum < min)
min = sum;
}
Console.WriteLine(min);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
var end = array.Max() * 2;
double min = double.MaxValue;
for (int i = 0; i < end; i++) {
double sum = 0;
for (int j = 0; j < array.Length; j++) {
sum += Math.Pow((array[j] - i), 2);
}
if (sum < min)
min = sum;
}
Console.WriteLine(min);
}
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 172
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class40 {
static void Main() {
int n = int.Parse(Console.ReadLine());
var x = Console.ReadLine().Split().Select(long.Parse).ToArray();
long sum = long.MaxValue;
for (long i = 0; i < x.Max(); i++) {
long k = 0;
for (int j = 0; j < n; j++) {
k += (long)Math.Pow(i - x[j], 2);
}
sum = Math.Min(sum, k);
}
Console.WriteLine(sum);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class40 {
static void Main() {
int n = int.Parse(Console.ReadLine());
var x = Console.ReadLine().Split().Select(long.Parse).ToArray();
long sum = long.MaxValue;
for (long i = 0; i <= x.Max(); i++) {
long k = 0;
for (int j = 0; j < n; j++) {
k += (long)Math.Pow(i - x[j], 2);
}
sum = Math.Min(sum, k);
}
Console.WriteLine(sum);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 165
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
namespace ABC156D {
class Program {
static void Main(string[] args) {
long[] nav = ReadLong();
long n = nav[0];
long a = nav[1];
long b = nav[2];
long mod = 1000000000 + 7;
// long[] pow = new long[64];
// pow[0] = 1;
// pow[1] = 2;
// for (int i = 2; i < pow.Length; i++)
//{
// pow[i] = (pow[i - 1] * pow[i - 1]) % mod;
//}
// long all = 0;
// for (int i = 0; i < pow.Length; i++)
//{
// var shift = n >> i;
// if (shift % 2 == 1) all = (all + pow[i + 1]) % mod;
//}
long all = Calc.ModPow(2, n, mod);
long nCa = Calc.nCk(n, a, mod);
long nCb = Calc.nCk(n, b, mod);
long ans = all - 1 - nCa - nCb;
if (ans < 0)
ans += mod;
Console.WriteLine(ans);
Console.ReadKey();
}
static int[] ReadInt() {
int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
return ret;
}
static long[] ReadLong() {
long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
return ret;
}
}
static class Calc {
/// <summary>
/// a^n (mod p)
/// nが非常に大きい時に有効
/// </summary>
/// <param name="a"></param>
/// <param name="n"></param>
/// <param name="mod"></param>
/// <returns></returns>
public static long ModPow(long a, long n, long p) {
if (n == 1)
return a % p;
if (n % 2 == 1)
return (a * ModPow(a, n - 1, p)) % p;
long t = ModPow(a, n / 2, p);
return (t * t) % p;
}
/// <summary>
/// 組み合わせ個数
/// </summary>
/// <param name="n"></param>
/// <param name="k"></param>
/// <param name="p"></param>
/// <returns></returns>
public static long nCk(long n, long k, long p) {
long ans = 1;
for (long i = n; i > n - k; i--) {
ans = (ans * i) % p;
}
for (long i = 1; i <= k; i++) {
ans = (ans * ModPow(i, p - 2, p)) % p;
}
return ans;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
namespace ABC156D {
class Program {
static void Main(string[] args) {
long[] nav = ReadLong();
long n = nav[0];
long a = nav[1];
long b = nav[2];
long mod = 1000000000 + 7;
// long[] pow = new long[64];
// pow[0] = 1;
// pow[1] = 2;
// for (int i = 2; i < pow.Length; i++)
//{
// pow[i] = (pow[i - 1] * pow[i - 1]) % mod;
//}
// long all = 0;
// for (int i = 0; i < pow.Length; i++)
//{
// var shift = n >> i;
// if (shift % 2 == 1) all = (all + pow[i + 1]) % mod;
//}
long all = Calc.ModPow(2, n, mod);
long nCa = Calc.nCk(n, a, mod);
long nCb = Calc.nCk(n, b, mod);
long ans = (all - 1 - nCa - nCb) % mod;
if (ans < 0)
ans += mod;
Console.WriteLine(ans);
Console.ReadKey();
}
static int[] ReadInt() {
int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
return ret;
}
static long[] ReadLong() {
long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
return ret;
}
}
static class Calc {
/// <summary>
/// a^n (mod p)
/// nが非常に大きい時に有効
/// </summary>
/// <param name="a"></param>
/// <param name="n"></param>
/// <param name="mod"></param>
/// <returns></returns>
public static long ModPow(long a, long n, long p) {
if (n == 1)
return a % p;
if (n % 2 == 1)
return (a * ModPow(a, n - 1, p)) % p;
long t = ModPow(a, n / 2, p);
return (t * t) % p;
}
/// <summary>
/// 組み合わせ個数
/// </summary>
/// <param name="n"></param>
/// <param name="k"></param>
/// <param name="p"></param>
/// <returns></returns>
public static long nCk(long n, long k, long p) {
long ans = 1;
for (long i = n; i > n - k; i--) {
ans = (ans * i) % p;
}
for (long i = 1; i <= k; i++) {
ans = (ans * ModPow(i, p - 2, p)) % p;
}
return ans;
}
}
}
|
[["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
| 8
| 431
| 4
|
using System;
using System.Linq;
class test {
static long mod = 1000000007;
public static void Main() {
var nab = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
long n = nab[0];
long a = nab[1];
long b = nab[2];
long res = Pow(2, n);
long A = Conv(n, a);
long B = Conv(n, b);
res = (res % mod) - (A % mod) - (B % mod) - 1;
if (res < 0) {
res = mod + res;
}
Console.WriteLine(res);
}
static long Pow(long x, long n) {
if (n == 1) {
return x % mod;
} else if (n % 2 == 1) {
return (x * Pow(x, n - 1)) % mod;
}
long z = Pow(x, n / 2);
return (z * z) % mod;
}
static long Conv(long n, long m) {
long x = 1;
long y = 1;
m = Math.Min(m, n - m);
while (m > 0) {
x *= n--;
x %= mod;
y *= m--;
y %= mod;
}
return (x * Pow(y, mod - 2)) % mod;
}
}
|
using System;
using System.Linq;
class test {
static long mod = 1000000007;
public static void Main() {
var nab = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
long n = nab[0];
long a = nab[1];
long b = nab[2];
long res = Pow(2, n);
long A = Conv(n, a);
long B = Conv(n, b);
res = ((res % mod) - (A % mod) - (B % mod) - 1) % mod;
if (res < 0) {
res = mod + res;
}
Console.WriteLine(res);
}
static long Pow(long x, long n) {
if (n == 1) {
return x % mod;
} else if (n % 2 == 1) {
return (x * Pow(x, n - 1)) % mod;
}
long z = Pow(x, n / 2);
return (z * z) % mod;
}
static long Conv(long n, long m) {
long x = 1;
long y = 1;
m = Math.Min(m, n - m);
while (m > 0) {
x *= n--;
x %= mod;
y *= m--;
y %= mod;
}
return (x * Pow(y, mod - 2)) % mod;
}
}
|
[["+", 0, 16, 31, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
| 8
| 305
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
public class Hello {
static public int mod = 1000000007;
public static void Main() {
int[] read = inta();
long max = square(2, read[0]) - 1;
long a1 = ncr(read[0], read[1]);
long a2 = ncr(read[0], read[2]);
long ans = max - a1 - a2;
if (ans < 0) {
ans += mod;
}
WriteLine(ans);
}
static int ncr(int n, int r) {
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
// static int square2(long a,long b,long m){var list = new List<int>();int
// temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp <
// b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b >
// 0){if(temp <= b){b -= temp;ret =
// ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;} 各種読取
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// スタック -> 深さ優先 ???
// if (list?.Count > 0) リストが空でもnullでもない
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
public class Hello {
static public int mod = 1000000007;
public static void Main() {
int[] read = inta();
long max = square(2, read[0]) - 1;
long a1 = ncr(read[0], read[1]);
long a2 = ncr(read[0], read[2]);
long ans = (max - a1 - a2) % mod;
if (ans < 0) {
ans += mod;
}
WriteLine(ans);
}
static int ncr(int n, int r) {
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
// static int square2(long a,long b,long m){var list = new List<int>();int
// temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp <
// b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b >
// 0){if(temp <= b){b -= temp;ret =
// ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;} 各種読取
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// スタック -> 深さ優先 ???
// if (list?.Count > 0) リストが空でもnullでもない
|
[["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
| 8
| 870
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
partial class Program {
static void Main(string[] args) { ABC156D(); }
static void ABC156A() {
var nr = ReadIntN();
var N = nr[0];
var R = nr[1];
Console.WriteLine(N >= 10 ? R : R + 100 * (10 - N));
}
static void ABC156B() {
var nk = ReadIntN();
var N = nk[0];
var K = nk[1];
int keta = 0;
while (N > 0) {
N /= K;
keta++;
}
Console.WriteLine(keta);
}
static void ABC156C() {
var N = ReadInt();
var X = ReadIntN();
int min = Int32.MaxValue;
for (int p = 1; p <= 100; ++p) {
var cost = X.Select(x => (x - p) * (x - p)).Sum();
min = Math.Min(min, cost);
}
Console.WriteLine(min);
}
static void ABC156D() {
var nab = ReadIntN();
var N = nab[0];
var A = nab[1];
var B = nab[2];
long total = Util.Power2(N, Util.P) - 1;
var combin = Util.CombinLarge(B, Util.P);
total = (total + Util.P * 2 - combin(N, A)) % Util.P;
total = (total + Util.P * 2 - combin(N, B)) % Util.P;
Console.WriteLine(total);
}
static void ABC156E() {
var nk = ReadIntN();
var N = nk[0];
var K = nk[1];
var func = Util.Combin(N * 2, Util.P);
if (N <= K) {
Console.WriteLine(func(N * 2 - 1, N));
return;
}
long total = 0;
for (int i = 0; i <= K; ++i) {
var c1 = func(N, i);
var c2 = func(N - 1, i);
total = (total + c1 * c2) % Util.P;
}
Console.WriteLine(total);
}
static void ABC156F() {
var kq = ReadIntN();
var D = ReadLongN();
var K = kq[0];
for (var q = 0; q < kq[1]; ++q) {
var nxm = ReadLongN();
var N = nxm[0];
var X = nxm[1];
var M = nxm[2];
var D2 = D.Select(x => x % M).ToArray();
var D2Sum = Util.Sum(D2);
var count0 = Util.Count(D2, 0);
var D2SumFirst = Util.Sum(D2, (int)((N - 1) % K));
var D20First = Util.Count(D2, 0, (int)((N - 1) % K));
var last = (X % M) + ((N - 1) / K) * D2Sum + D2SumFirst;
var zero = ((N - 1) / K) * count0 + D20First;
var des = last / M;
Console.WriteLine(N - des - zero - 1);
}
}
class Util {
public static readonly long P = 1000000007;
public static long Sum(long[] array) { return Sum(array, array.Length); }
public static long Sum(long[] array, int n) {
long total = 0;
for (int i = 0; i < n; ++i) {
total += array[i];
}
return total;
}
public static long Count(long[] array, long x) {
return Count(array, x, array.Length);
}
public static long Count(long[] array, long x, int n) {
long total = 0;
for (int i = 0; i < n; ++i) {
total += (array[i] == x ? 1 : 0);
}
return total;
}
public static long GCD(long a, long b) {
while (a % b > 0) {
var c = a % b;
a = b;
b = c;
}
return b;
}
public static Dictionary<long, int> Factorize(long x) {
var dict = new Dictionary<long, int>();
long minp = 2;
while (x > 1) {
bool ok = false;
for (long p = minp; p * p <= x; ++p) {
if (x % p == 0) {
if (!dict.ContainsKey(p)) {
dict.Add(p, 0);
}
dict[p]++;
minp = p;
x /= p;
ok = true;
break;
}
}
if (!ok) {
if (!dict.ContainsKey(x)) {
dict.Add(x, 0);
}
dict[x]++;
break;
}
}
return dict;
}
public static long Inverse(long a, long p) {
long b = p, c = 1, d = 0, e = 0, f = 0;
while (b != 0) {
e = a / b;
f = b;
b = a - e * b;
a = f;
f = d;
d = c - e * d;
c = f;
}
c %= p;
return c + (c < 0 ? p : 0);
}
public static long[] Facts(int n, long p) {
var facts = new long[n + 1];
facts[0] = 1;
for (int i = 1; i <= n; ++i) {
facts[i] = (i * facts[i - 1]) % p;
}
return facts;
}
public static Func<int, int, long> Combin(int n, long P) {
var fact = Facts(n, P);
var inv = fact.Select(x => Inverse(x, P)).ToArray();
return (N, M) => {
if (N < 0 || N < M || M < 0) {
return 0;
}
return (((fact[N] * inv[M]) % P) * inv[N - M]) % P;
};
}
/// <summary>
/// Calc Combin(n,m) where n is large and m<=mMax
/// </summary>
public static Func<int, int, long> CombinLarge(int mMax, long p) {
var inv = Enumerable.Range(0, mMax + 1)
.Select(x => Util.Inverse(x, Util.P))
.ToArray();
return (n, m) => {
long mult = 1;
for (int i = 1; i <= m; ++i) {
mult = (((mult * (n + 1 - i)) % Util.P) * inv[i]) % Util.P;
}
return mult;
};
}
/// <summary>
/// Calc 2^n mod p
/// </summary>
public static long Power2(long n, long p) {
long res = 1;
long mult = 2;
for (int i = 0; i < 40; ++i) {
if ((n & (1 << i)) > 0) {
res = (res * mult) % p;
mult = (mult * mult) % p;
}
}
return res;
}
}
class Geometric {
/// <summary>
/// 2点間の距離
/// </summary>
public static double Distance(Tuple<double, double> s,
Tuple<double, double> t) {
var diff1 = s.Item1 - t.Item1;
var diff2 = s.Item2 - t.Item2;
return Math.Sqrt(diff1 * diff1 + diff2 * diff2);
}
/// <summary>
/// 2点の中点
/// </summary>
public static Tuple<double, double> Center(Tuple<double, double> s,
Tuple<double, double> t) {
return new Tuple<double, double>((s.Item1 + t.Item1) / 2,
(s.Item2 + t.Item2) / 2);
}
/// <summary>
/// 垂直二等分線 ax+by+c=0の係数(a,b,c)を出力
/// </summary>
public static Tuple<double, double, double>
Bisector(Tuple<double, double> s, Tuple<double, double> t) {
var a = t.Item1 - s.Item1;
var b = t.Item2 - s.Item2;
var c = -a * (s.Item1 + t.Item1) / 2 - b * (s.Item2 + t.Item2) / 2;
return new Tuple<double, double, double>(a, b, c);
}
/// <summary>
/// 2本の直線が平行か(絶対誤差Epsilon)
/// </summary>
public static bool IsParallel(Tuple<double, double, double> line1,
Tuple<double, double, double> line2,
double epsilon) {
return Math.Abs(line1.Item1 * line2.Item2 - line1.Item2 * line2.Item1) <
epsilon;
}
/// <summary>
/// 2本の直線の交点(平行でないことを仮定)
/// </summary>
public static Tuple<double, double>
Intersection(Tuple<double, double, double> line1,
Tuple<double, double, double> line2) {
var div = line1.Item1 * line2.Item2 - line1.Item2 * line2.Item1;
var x = (line1.Item2 * line2.Item3 - line1.Item3 * line2.Item2) / div;
var y = (line1.Item3 * line2.Item1 - line1.Item1 * line2.Item3) / div;
return new Tuple<double, double>(x, y);
}
}
static string ReadStr() { return Console.ReadLine(); }
static string[] ReadStrN() { return Console.ReadLine().Split(' '); }
static int ReadInt() { return Convert.ToInt32(Console.ReadLine()); }
static int[] ReadIntN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt32(s))
.ToArray();
}
static long ReadLong() { return Convert.ToInt64(Console.ReadLine()); }
static long[] ReadLongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt64(s))
.ToArray();
}
static Tuple<string, string>[] ReadTupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = ReadStrN();
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<long, long>[] ReadTupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongN();
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<double, double>[] ReadTupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongN();
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
partial class Program {
static void Main(string[] args) { ABC156D(); }
static void ABC156A() {
var nr = ReadIntN();
var N = nr[0];
var R = nr[1];
Console.WriteLine(N >= 10 ? R : R + 100 * (10 - N));
}
static void ABC156B() {
var nk = ReadIntN();
var N = nk[0];
var K = nk[1];
int keta = 0;
while (N > 0) {
N /= K;
keta++;
}
Console.WriteLine(keta);
}
static void ABC156C() {
var N = ReadInt();
var X = ReadIntN();
int min = Int32.MaxValue;
for (int p = 1; p <= 100; ++p) {
var cost = X.Select(x => (x - p) * (x - p)).Sum();
min = Math.Min(min, cost);
}
Console.WriteLine(min);
}
static void ABC156D() {
var nab = ReadIntN();
var N = nab[0];
var A = nab[1];
var B = nab[2];
long total = Util.Power2(N, Util.P) - 1;
var combin = Util.CombinLarge(B, Util.P);
total = (total + Util.P * 2 - combin(N, A)) % Util.P;
total = (total + Util.P * 2 - combin(N, B)) % Util.P;
Console.WriteLine(total);
}
static void ABC156E() {
var nk = ReadIntN();
var N = nk[0];
var K = nk[1];
var func = Util.Combin(N * 2, Util.P);
if (N <= K) {
Console.WriteLine(func(N * 2 - 1, N));
return;
}
long total = 0;
for (int i = 0; i <= K; ++i) {
var c1 = func(N, i);
var c2 = func(N - 1, i);
total = (total + c1 * c2) % Util.P;
}
Console.WriteLine(total);
}
static void ABC156F() {
var kq = ReadIntN();
var D = ReadLongN();
var K = kq[0];
for (var q = 0; q < kq[1]; ++q) {
var nxm = ReadLongN();
var N = nxm[0];
var X = nxm[1];
var M = nxm[2];
var D2 = D.Select(x => x % M).ToArray();
var D2Sum = Util.Sum(D2);
var count0 = Util.Count(D2, 0);
var D2SumFirst = Util.Sum(D2, (int)((N - 1) % K));
var D20First = Util.Count(D2, 0, (int)((N - 1) % K));
var last = (X % M) + ((N - 1) / K) * D2Sum + D2SumFirst;
var zero = ((N - 1) / K) * count0 + D20First;
var des = last / M;
Console.WriteLine(N - des - zero - 1);
}
}
class Util {
public static readonly long P = 1000000007;
public static long Sum(long[] array) { return Sum(array, array.Length); }
public static long Sum(long[] array, int n) {
long total = 0;
for (int i = 0; i < n; ++i) {
total += array[i];
}
return total;
}
public static long Count(long[] array, long x) {
return Count(array, x, array.Length);
}
public static long Count(long[] array, long x, int n) {
long total = 0;
for (int i = 0; i < n; ++i) {
total += (array[i] == x ? 1 : 0);
}
return total;
}
public static long GCD(long a, long b) {
while (a % b > 0) {
var c = a % b;
a = b;
b = c;
}
return b;
}
public static Dictionary<long, int> Factorize(long x) {
var dict = new Dictionary<long, int>();
long minp = 2;
while (x > 1) {
bool ok = false;
for (long p = minp; p * p <= x; ++p) {
if (x % p == 0) {
if (!dict.ContainsKey(p)) {
dict.Add(p, 0);
}
dict[p]++;
minp = p;
x /= p;
ok = true;
break;
}
}
if (!ok) {
if (!dict.ContainsKey(x)) {
dict.Add(x, 0);
}
dict[x]++;
break;
}
}
return dict;
}
public static long Inverse(long a, long p) {
long b = p, c = 1, d = 0, e = 0, f = 0;
while (b != 0) {
e = a / b;
f = b;
b = a - e * b;
a = f;
f = d;
d = c - e * d;
c = f;
}
c %= p;
return c + (c < 0 ? p : 0);
}
public static long[] Facts(int n, long p) {
var facts = new long[n + 1];
facts[0] = 1;
for (int i = 1; i <= n; ++i) {
facts[i] = (i * facts[i - 1]) % p;
}
return facts;
}
public static Func<int, int, long> Combin(int n, long P) {
var fact = Facts(n, P);
var inv = fact.Select(x => Inverse(x, P)).ToArray();
return (N, M) => {
if (N < 0 || N < M || M < 0) {
return 0;
}
return (((fact[N] * inv[M]) % P) * inv[N - M]) % P;
};
}
/// <summary>
/// Calc Combin(n,m) where n is large and m<=mMax
/// </summary>
public static Func<int, int, long> CombinLarge(int mMax, long p) {
var inv = Enumerable.Range(0, mMax + 1)
.Select(x => Util.Inverse(x, Util.P))
.ToArray();
return (n, m) => {
long mult = 1;
for (int i = 1; i <= m; ++i) {
mult = (((mult * (n + 1 - i)) % Util.P) * inv[i]) % Util.P;
}
return mult;
};
}
/// <summary>
/// Calc 2^n mod p
/// </summary>
public static long Power2(long n, long p) {
long res = 1;
long mult = 2;
for (int i = 0; i < 40; ++i) {
if ((n & ((long)1 << i)) > 0) {
res = (res * mult) % p;
}
mult = (mult * mult) % p;
}
return res;
}
}
class Geometric {
/// <summary>
/// 2点間の距離
/// </summary>
public static double Distance(Tuple<double, double> s,
Tuple<double, double> t) {
var diff1 = s.Item1 - t.Item1;
var diff2 = s.Item2 - t.Item2;
return Math.Sqrt(diff1 * diff1 + diff2 * diff2);
}
/// <summary>
/// 2点の中点
/// </summary>
public static Tuple<double, double> Center(Tuple<double, double> s,
Tuple<double, double> t) {
return new Tuple<double, double>((s.Item1 + t.Item1) / 2,
(s.Item2 + t.Item2) / 2);
}
/// <summary>
/// 垂直二等分線 ax+by+c=0の係数(a,b,c)を出力
/// </summary>
public static Tuple<double, double, double>
Bisector(Tuple<double, double> s, Tuple<double, double> t) {
var a = t.Item1 - s.Item1;
var b = t.Item2 - s.Item2;
var c = -a * (s.Item1 + t.Item1) / 2 - b * (s.Item2 + t.Item2) / 2;
return new Tuple<double, double, double>(a, b, c);
}
/// <summary>
/// 2本の直線が平行か(絶対誤差Epsilon)
/// </summary>
public static bool IsParallel(Tuple<double, double, double> line1,
Tuple<double, double, double> line2,
double epsilon) {
return Math.Abs(line1.Item1 * line2.Item2 - line1.Item2 * line2.Item1) <
epsilon;
}
/// <summary>
/// 2本の直線の交点(平行でないことを仮定)
/// </summary>
public static Tuple<double, double>
Intersection(Tuple<double, double, double> line1,
Tuple<double, double, double> line2) {
var div = line1.Item1 * line2.Item2 - line1.Item2 * line2.Item1;
var x = (line1.Item2 * line2.Item3 - line1.Item3 * line2.Item2) / div;
var y = (line1.Item3 * line2.Item1 - line1.Item1 * line2.Item3) / div;
return new Tuple<double, double>(x, y);
}
}
static string ReadStr() { return Console.ReadLine(); }
static string[] ReadStrN() { return Console.ReadLine().Split(' '); }
static int ReadInt() { return Convert.ToInt32(Console.ReadLine()); }
static int[] ReadIntN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt32(s))
.ToArray();
}
static long ReadLong() { return Convert.ToInt64(Console.ReadLine()); }
static long[] ReadLongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt64(s))
.ToArray();
}
static Tuple<string, string>[] ReadTupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = ReadStrN();
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<long, long>[] ReadTupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongN();
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<double, double>[] ReadTupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongN();
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
}
}
|
[["+", 0, 16, 12, 23, 0, 16, 31, 74, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 31, 74, 39, 199], ["+", 0, 16, 12, 23, 0, 16, 31, 74, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 2,398
| 5
|
using static System.Math;
using System;
class Modulo {
private const int MOD = 1000000007;
private readonly int[] m_facs;
public int Mul(int a, int b) => (int)(Math.BigMul(a, b) % MOD);
public Modulo(int n) {
m_facs = new int[n + 1];
m_facs[0] = 1;
for (int i = 1; i <= n; ++i)
m_facs[i] = Mul(m_facs[i - 1], i);
}
public int Fac(int n) => m_facs[n];
public int Pow(int a, int m) {
switch (m) {
case 0:
return 1;
case 1:
return a;
default:
int p1 = Pow(a, m / 2);
int p2 = Mul(p1, p1);
return ((m % 2) == 0) ? p2 : Mul(p2, a);
}
}
public int Div(int a, int b) => Mul(a, Pow(b, MOD - 2));
public int Ncr(int n, int r) {
if (n < r)
return 0;
if (n == r)
return 1;
int res = Fac(n);
res = Div(res, Fac(r));
res = Div(res, Fac(n - r));
return res;
}
}
public class Hello {
public const int MOD = 1000000007;
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var a = int.Parse(line[1]);
var b = int.Parse(line[2]);
var c = new Modulo(Max(a, b));
var ans1 = c.Pow(2, n);
var ans2 = c.Div(getFac(n, a), c.Fac(a));
var ans3 = c.Div(getFac(n, b), c.Fac(b));
long ans = (ans1 - ans2 - ans3) % MOD;
if (ans < 0)
ans += MOD;
Console.WriteLine(ans);
}
static int getFac(int n, int a) {
var ans = 1L;
for (int i = n - a + 1; i <= n; i++) {
ans *= i;
ans %= MOD;
}
return (int)ans;
}
}
|
using static System.Math;
using System;
class Modulo {
private const int MOD = 1000000007;
private readonly int[] m_facs;
public int Mul(int a, int b) => (int)(Math.BigMul(a, b) % MOD);
public Modulo(int n) {
m_facs = new int[n + 1];
m_facs[0] = 1;
for (int i = 1; i <= n; ++i)
m_facs[i] = Mul(m_facs[i - 1], i);
}
public int Fac(int n) => m_facs[n];
public int Pow(int a, int m) {
switch (m) {
case 0:
return 1;
case 1:
return a;
default:
int p1 = Pow(a, m / 2);
int p2 = Mul(p1, p1);
return ((m % 2) == 0) ? p2 : Mul(p2, a);
}
}
public int Div(int a, int b) => Mul(a, Pow(b, MOD - 2));
public int Ncr(int n, int r) {
if (n < r)
return 0;
if (n == r)
return 1;
int res = Fac(n);
res = Div(res, Fac(r));
res = Div(res, Fac(n - r));
return res;
}
}
public class Hello {
public const int MOD = 1000000007;
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var a = int.Parse(line[1]);
var b = int.Parse(line[2]);
var c = new Modulo(Max(a, b));
var ans1 = c.Pow(2, n) - 1;
var ans2 = c.Div(getFac(n, a), c.Fac(a));
var ans3 = c.Div(getFac(n, b), c.Fac(b));
long ans = (ans1 - ans2 - ans3) % MOD;
if (ans < 0)
ans += MOD;
Console.WriteLine(ans);
}
static int getFac(int n, int a) {
var ans = 1L;
for (int i = n - a + 1; i <= n; i++) {
ans *= i;
ans %= MOD;
}
return (int)ans;
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 521
| 2
|
using System;
using System.Linq;
namespace ABC156 {
class D {
static void Main(string[] args) {
long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
long n = input[0];
long a = input[1];
long b = input[2];
long mod = 1000000007;
long total = modPow(2, n, mod) - 1;
long ca = modCombination(n, a, mod);
long cb = modCombination(n, b, mod);
Console.WriteLine((total + mod - (ca + cb)) % mod);
}
public static long modPow(long a, long n, long mod) {
long res = 1;
while (n > 0) {
if ((n & 1) > 0)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res % mod;
}
public static long modInv(long a, long mod) {
return modPow(a, mod - 2, mod) % mod;
}
public static long modMul(long a, long b, long mod) {
return ((a % mod) * (b % mod)) % mod;
}
public static long modDiv(long a, long b, long mod) {
return modMul(a, modInv(b, mod), mod);
}
private static long modCombination(long n, long k, long mod) {
long answer = 1;
for (long i = n; i > n - k; i--) {
answer = modMul(answer, i, mod);
}
for (long i = 1; i <= k; i++) {
answer = modDiv(answer, i, mod);
}
return answer;
}
}
}
|
using System;
using System.Linq;
namespace ABC156 {
class D {
static void Main(string[] args) {
long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
long n = input[0];
long a = input[1];
long b = input[2];
long mod = 1000000007;
long total = modPow(2, n, mod) - 1;
long ca = modCombination(n, a, mod) % mod;
long cb = modCombination(n, b, mod) % mod;
Console.WriteLine((total + mod - (ca + cb) % mod) % mod);
}
public static long modPow(long a, long n, long mod) {
long res = 1;
while (n > 0) {
if ((n & 1) > 0)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res % mod;
}
public static long modInv(long a, long mod) {
return modPow(a, mod - 2, mod) % mod;
}
public static long modMul(long a, long b, long mod) {
return ((a % mod) * (b % mod)) % mod;
}
public static long modDiv(long a, long b, long mod) {
return modMul(a, modInv(b, mod), mod);
}
private static long modCombination(long n, long k, long mod) {
long answer = 1;
for (long i = n; i > n - k; i--) {
answer = modMul(answer, i, mod);
}
for (long i = 1; i <= k; i++) {
answer = modDiv(answer, i, mod);
}
return answer;
}
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 17, 109], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 12, 22]]
| 8
| 374
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999;
public static void Main(string[] args) {
var p = Input();
var n = p[0].ToLong();
var a = p[1].ToInt();
var b = p[2].ToInt();
long wa = ModPow(2, n, Giri) - 1;
long wa2 = 0;
wa2 += Combination(n, a);
wa2 %= Giri;
wa2 += Combination(n, b);
wa2 %= Giri;
Console.WriteLine((wa - wa2) % Giri);
}
static long Combination(long n, long k) {
long q = 1;
long s = 1;
long j = 1;
for (long i = n; i >= n - k + 1; i--) {
q *= i % Giri;
q %= Giri;
s *= ModPow(j, Giri - 2, Giri) % Giri;
s %= Giri;
j++;
}
return (long)(q * s) % Giri;
}
static long ModPow(long a, long n, long mod) {
long res = 1;
while (n > 0) {
if ((n & 1) == 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999;
public static void Main(string[] args) {
var p = Input();
var n = p[0].ToLong();
var a = p[1].ToInt();
var b = p[2].ToInt();
long wa = ModPow(2, n, Giri) - 1;
long wa2 = 0;
wa2 += Combination(n, a);
wa2 %= Giri;
wa2 += Combination(n, b);
wa2 %= Giri;
Console.WriteLine((wa + Giri - wa2) % Giri);
}
static long Combination(long n, long k) {
long q = 1;
long s = 1;
long j = 1;
for (long i = n; i >= n - k + 1; i--) {
q *= i % Giri;
q %= Giri;
s *= ModPow(j, Giri - 2, Giri) % Giri;
s %= Giri;
j++;
}
return (long)(q * s) % Giri;
}
static long ModPow(long a, long n, long mod) {
long res = 1;
while (n > 0) {
if ((n & 1) == 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
[["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22]]
| 8
| 498
| 2
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AtCoder {
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.OrdinalIgnoreCase);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class AtCoder {
public string GetStr() { return Console.ReadLine().Trim(); }
public char GetChar() { return Console.ReadLine().Trim()[0]; }
public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<int>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<int>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
dic[a].Add(b);
if (isDirected == false)
dic[b].Add(a);
}
return dic;
}
Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<Edge>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<Edge>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
var c = input[2];
dic[a].Add(new Edge(b, c));
if (isDirected == false)
dic[b].Add(new Edge(a, c));
}
return dic;
}
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
void Multi<T>(out T a) => a = cv<T>(GetStr());
void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e,
out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
class Edge {
public Edge(int to, long length) {
To = to;
Length = length;
}
public int To { get; set; }
public long Length { get; set; }
}
partial class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new AtCoder().Solve();
Console.Out.Flush();
Console.Read();
}
}
public partial class AtCoder {
public void Solve() {
long mod = 1000000007;
int N;
long K;
Multi(out N, out K);
var mc = new ModCombination();
if (K >= N - 1) {
Console.WriteLine(mc.Combination(2 * N - 1, N));
return;
} else {
long sum = 0;
for (int i = 0; i <= K; i++) {
sum =
sum + mc.Combination(N, i) * mc.Combination(N - 1, N - 1 - i) % mod;
}
Console.WriteLine(sum);
}
}
}
class ModCombination {
static long mod = 1000000007;
static int max = 1000000;
long[] fac = new long[max];
long[] finv = new long[max];
long[] inv = new long[max];
/// <summary>
/// fac,finv,invの事前計算
/// n<maxをみたすO(max)
/// </summary>
public ModCombination() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
/// <summary>
/// O(1)
/// </summary>
public long Combination(int n, int m) {
if (n < m)
return 0;
if (n < 0 || m < 0)
return 0;
return fac[n] * (finv[m] * finv[n - m] % mod) % mod;
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AtCoder {
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.OrdinalIgnoreCase);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class AtCoder {
public string GetStr() { return Console.ReadLine().Trim(); }
public char GetChar() { return Console.ReadLine().Trim()[0]; }
public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<int>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<int>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
dic[a].Add(b);
if (isDirected == false)
dic[b].Add(a);
}
return dic;
}
Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<Edge>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<Edge>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
var c = input[2];
dic[a].Add(new Edge(b, c));
if (isDirected == false)
dic[b].Add(new Edge(a, c));
}
return dic;
}
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
void Multi<T>(out T a) => a = cv<T>(GetStr());
void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e,
out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
class Edge {
public Edge(int to, long length) {
To = to;
Length = length;
}
public int To { get; set; }
public long Length { get; set; }
}
partial class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new AtCoder().Solve();
Console.Out.Flush();
Console.Read();
}
}
public partial class AtCoder {
public void Solve() {
long mod = 1000000007;
int N;
long K;
Multi(out N, out K);
var mc = new ModCombination();
if (K >= N - 1) {
Console.WriteLine(mc.Combination(2 * N - 1, N));
return;
} else {
long sum = 0;
for (int i = 0; i <= K; i++) {
sum = (sum +
mc.Combination(N, i) * mc.Combination(N - 1, N - 1 - i) % mod) %
mod;
}
Console.WriteLine(sum);
}
}
}
class ModCombination {
static long mod = 1000000007;
static int max = 1000000;
long[] fac = new long[max];
long[] finv = new long[max];
long[] inv = new long[max];
/// <summary>
/// fac,finv,invの事前計算
/// n<maxをみたすO(max)
/// </summary>
public ModCombination() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
/// <summary>
/// O(1)
/// </summary>
public long Combination(int n, int m) {
if (n < m)
return 0;
if (n < 0 || m < 0)
return 0;
return fac[n] * (finv[m] * finv[n - m] % mod) % mod;
}
}
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 17, 109], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 12, 22]]
| 8
| 2,051
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P {
public static void Main() {
// Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush
// = false });
var kq = Console.ReadLine().Split().Select(int.Parse).ToArray();
var d = Console.ReadLine().Split().Select(int.Parse).ToArray();
var k = kq[0];
var q = kq[1];
long[] seq = new long[d.Length + 1];
for (int _ = 0; _ < q; _++) {
var nxm = Console.ReadLine().Split().Select(long.Parse).ToArray();
var n = nxm[0];
var X = nxm[1];
var m = nxm[2];
seq[0] = 0;
for (int i = 0; i < d.Length; i++) {
var add = d[i] % m;
if (add == 0)
add = m;
seq[i + 1] = seq[i] + add;
}
var sum = (n / d.Length) * seq.Last();
var remain = seq[(n - 1) % d.Length];
sum = (X % m) + sum + remain;
Console.WriteLine(n - 1 - sum / m);
}
// Console.Out.Flush();
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P {
public static void Main() {
// Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush
// = false });
var kq = Console.ReadLine().Split().Select(int.Parse).ToArray();
var d = Console.ReadLine().Split().Select(int.Parse).ToArray();
var k = kq[0];
var q = kq[1];
long[] seq = new long[d.Length + 1];
for (int _ = 0; _ < q; _++) {
var nxm = Console.ReadLine().Split().Select(long.Parse).ToArray();
var n = nxm[0];
var X = nxm[1];
var m = nxm[2];
seq[0] = 0;
for (int i = 0; i < d.Length; i++) {
var add = d[i] % m;
if (add == 0)
add = m;
seq[i + 1] = seq[i] + add;
}
var sum = ((n - 1) / d.Length) * seq.Last();
var remain = seq[(n - 1) % d.Length];
sum = (X % m) + sum + remain;
Console.WriteLine(n - 1 - sum / m);
}
// Console.Out.Flush();
}
}
|
[["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 25]]
| 8
| 359
| 4
|
using System;
namespace ABC155A {
class Program {
static void Main(string[] args) {
string[] word = Console.ReadLine().Split(' ');
int a = int.Parse(word[0]);
int h = int.Parse(word[1]);
int n = int.Parse(word[2]);
if (a == h && h != n || n != a)
Console.WriteLine("Yes");
else if (a == n && a != h || h != n)
Console.WriteLine("Yes");
else if (n == h && n != a || a != h)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
namespace ABC155A {
class Program {
static void Main(string[] args) {
string[] word = Console.ReadLine().Split(' ');
int a = int.Parse(word[0]);
int h = int.Parse(word[1]);
int n = int.Parse(word[2]);
if (a == h && (h != n || n != a))
Console.WriteLine("Yes");
else if (a == n && (a != h || h != n))
Console.WriteLine("Yes");
else if (n == h && (n != a || a != h))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 57, 15, 16, 12, 23, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 12, 23, 0, 25], ["+", 75, 57, 75, 57, 15, 16, 12, 23, 0, 24], ["+", 75, 57, 75, 57, 15, 16, 12, 23, 0, 25]]
| 8
| 160
| 6
|
using System;
namespace q1 {
class q2 {
static void Main() {
string[] x = Console.ReadLine().Split();
if (x[0] == x[1] && x[1] == x[2] ||
x[0] != x[1] && x[1] != x[2] && x[1] != x[2]) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
}
}
|
using System;
namespace q1 {
class q2 {
static void Main() {
string[] x = Console.ReadLine().Split();
if (x[0] == x[1] && x[1] == x[2] ||
x[0] != x[1] && x[1] != x[2] && x[0] != x[2]) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
}
}
|
[["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 108
| 2
|
using System;
class Prpgram {
static void Main(string[] args) {
string input = Console.ReadLine();
string[] inputlist = input.Split(' ');
string A = inputlist[0];
string B = inputlist[1];
string C = inputlist[2];
if (A == B && A == C)
Console.Write("No");
else if (A != B && A != C)
Console.Write("No");
else if (A == B && A != C)
Console.Write("Yes");
else if (A == C && A != B)
Console.Write("Yes");
else if (B == C && A != B)
Console.Write("Yes");
}
}
|
using System;
class Prpgram {
static void Main(string[] args) {
string input = Console.ReadLine();
string[] inputlist = input.Split(' ');
string A = inputlist[0];
string B = inputlist[1];
string C = inputlist[2];
if (A == B && A == C)
Console.Write("No");
else if (A != B && A != C && B != C)
Console.Write("No");
else if (A == B && A != C)
Console.Write("Yes");
else if (A == C && A != B)
Console.Write("Yes");
else if (B == C && A != B)
Console.Write("Yes");
}
}
|
[["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 98], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 79], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 164
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
class Ho {
static void Main() {
var aho = Console.ReadLine().Split();
if (aho[0] == aho[1] && aho[1] == aho[2]) {
Console.WriteLine("No");
} else if (aho[0] != aho[1] && aho[0] == aho[2] && aho[1] == aho[2]) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Ho {
static void Main() {
var aho = Console.ReadLine().Split();
if (aho[0] == aho[1] && aho[1] == aho[2]) {
Console.WriteLine("No");
} else if (aho[0] != aho[1] && aho[0] != aho[2] && aho[1] != aho[2]) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
}
|
[["-", 75, 57, 15, 16, 31, 16, 12, 16, 17, 60], ["+", 75, 57, 15, 16, 31, 16, 12, 16, 17, 79], ["-", 0, 57, 75, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 79]]
| 8
| 128
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var strarr = Console.ReadLine().Split();
var a = int.Parse(strarr[0]);
var b = int.Parse(strarr[1]);
var c = int.Parse(strarr[2]);
if (a == b) {
if (b == c)
Console.WriteLine("No");
else
Console.WriteLine("Yes");
} else {
if (b == c)
Console.WriteLine("Yes");
else if (a == c) {
Console.WriteLine("Yes");
}
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var strarr = Console.ReadLine().Split();
var a = int.Parse(strarr[0]);
var b = int.Parse(strarr[1]);
var c = int.Parse(strarr[2]);
if (a == b) {
if (b == c)
Console.WriteLine("No");
else
Console.WriteLine("Yes");
} else {
if (b == c)
Console.WriteLine("Yes");
else if (a == c) {
Console.WriteLine("Yes");
} else
Console.WriteLine("No");
}
}
}
}
|
[["+", 0, 57, 75, 196, 0, 57, 75, 57, 0, 95]]
| 8
| 176
| 1
|
using System;
class Program {
static void Main(string[] args) {
string[] numbers = Console.ReadLine().Split(' ');
var c = 0;
if (int.Parse(numbers[0]) + int.Parse(numbers[1]) + int.Parse(numbers[2]) ==
int.Parse(numbers[0]) * 3) {
Console.WriteLine("No");
return;
}
for (var i = 0; i < 2; i++) {
for (var j = i; j < 3; j++) {
if (numbers[i] == numbers[j])
c++;
}
}
if (c == 1) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] numbers = Console.ReadLine().Split(' ');
var c = 0;
if (int.Parse(numbers[0]) + int.Parse(numbers[1]) + int.Parse(numbers[2]) ==
int.Parse(numbers[0]) * 3) {
Console.WriteLine("No");
return;
}
for (var i = 0; i < 2; i++) {
for (var j = i + 1; j < 3; j++) {
if (numbers[i] == numbers[j])
c++;
}
}
if (c == 1) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 174
| 2
|
using System;
public class Program {
public static void Main() {
var sp = Console.ReadLine().Split();
if (sp[0] == sp[1] && sp[0] != sp[2])
Console.WriteLine("YES");
else if (sp[0] == sp[2] && sp[1] != sp[2])
Console.WriteLine("YES");
else if (sp[2] == sp[1] && sp[0] != sp[2])
Console.WriteLine("YES");
else
Console.WriteLine("No");
}
}
|
using System;
public class Program {
public static void Main() {
var sp = Console.ReadLine().Split();
if (sp[0] == sp[1] && sp[0] != sp[2])
Console.WriteLine("Yes");
else if (sp[0] == sp[2] && sp[1] != sp[2])
Console.WriteLine("Yes");
else if (sp[2] == sp[1] && sp[0] != sp[2])
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 134
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
public static void Main() {
string[] temp = Console.ReadLine().Split();
int[] A = new int[3];
for (int i = 0; i < 3; i++) {
A[i] = int.Parse(temp[i]);
}
Array.Sort(A);
if (A[0] == A[1] && A[1] == A[2] && A[0] != A[2]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
public static void Main() {
string[] temp = Console.ReadLine().Split();
int[] A = new int[3];
for (int i = 0; i < 3; i++) {
A[i] = int.Parse(temp[i]);
}
Array.Sort(A);
if ((A[0] == A[1] || A[1] == A[2]) && A[0] != A[2]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25]]
| 8
| 146
| 4
|
using System;
namespace ABC155A {
class Program {
static void Main(string[] args) {
int a, b, c;
string[] ss = Console.ReadLine().Split(' ');
a = int.Parse(ss[0]);
b = int.Parse(ss[1]);
c = int.Parse(ss[2]);
if (a == b && b == c)
Console.WriteLine("No");
else if (a != b && b != c)
Console.WriteLine("No");
else
Console.WriteLine("Yes");
Console.ReadKey();
}
}
}
|
using System;
namespace ABC155A {
class Program {
static void Main(string[] args) {
int a, b, c;
string[] ss = Console.ReadLine().Split(' ');
a = int.Parse(ss[0]);
b = int.Parse(ss[1]);
c = int.Parse(ss[2]);
if (a == b && b == c)
Console.WriteLine("No");
else if (a != b && b != c && a != c)
Console.WriteLine("No");
else
Console.WriteLine("Yes");
Console.ReadKey();
}
}
}
|
[["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 98], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 79], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 138
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderBeginnerContest155 {
class Program {
static void Main(string[] args) {
var numbers = ReadIntArray();
if (numbers.Distinct().Count() == 2) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
public static int ReadInt() => int.Parse(Console.ReadLine());
public static int[] ReadIntArray() =>
Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
public static long ReadLong() => long.Parse(Console.ReadLine());
public static long[] ReadLongArray() =>
Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
public static string ReadString() => Console.ReadLine();
public static string[] ReadStringArray() => Console.ReadLine().Split();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderBeginnerContest155 {
class Program {
static void Main(string[] args) {
var numbers = ReadIntArray();
if (numbers.Distinct().Count() == 2) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
public static int ReadInt() => int.Parse(Console.ReadLine());
public static int[] ReadIntArray() =>
Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
public static long ReadLong() => long.Parse(Console.ReadLine());
public static long[] ReadLongArray() =>
Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
public static string ReadString() => Console.ReadLine();
public static string[] ReadStringArray() => Console.ReadLine().Split();
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 216
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _3 {
class Program {
static void Main(string[] args) {
var one = Console.ReadLine();
int intone = one.Length;
string flag = "0";
string[] arrsplit = one.Split(' ');
string strone = arrsplit[0];
string strtwo = arrsplit[1];
string strthree = arrsplit[2];
if (strone == strtwo) {
flag = "1";
if (strone == strthree) {
flag = "0";
}
}
if (strone == strthree) {
flag = "1";
if (strtwo == strthree) {
flag = "0";
}
}
if (strtwo == strthree) {
flag = "1";
if (one == strthree) {
flag = "0";
}
}
if (flag == "1") {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _3 {
class Program {
static void Main(string[] args) {
var one = Console.ReadLine();
int intone = one.Length;
string flag = "0";
string[] arrsplit = one.Split(' ');
string strone = arrsplit[0];
string strtwo = arrsplit[1];
string strthree = arrsplit[2];
if (strone == strtwo) {
flag = "1";
if (strone == strthree) {
flag = "0";
}
}
if (strone == strthree) {
flag = "1";
if (strtwo == strthree) {
flag = "0";
}
}
if (strtwo == strthree) {
flag = "1";
if (strone == strthree) {
flag = "0";
}
}
if (flag == "1") {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22]]
| 8
| 222
| 2
|
using System;
namespace abc153a {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
int c = int.Parse(str[2]);
if (a == b && b != c && a != c)
Console.WriteLine("Yes");
if (a == c && a != b && b != c)
Console.WriteLine("Yes");
if (b == c && a != b && a != c)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
namespace abc153a {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
int c = int.Parse(str[2]);
if (a == b && b != c && a != c)
Console.WriteLine("Yes");
else if (a == c && a != b && b != c)
Console.WriteLine("Yes");
else if (b == c && a != b && a != c)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95]]
| 8
| 158
| 2
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string ABC = Console.ReadLine();
string[] split = ABC.Split();
int A = int.Parse(split[0]);
int B = int.Parse(split[1]);
int C = int.Parse(split[2]);
if (A == B || A == C || B == C) {
if (A == B && B == C) {
Console.WriteLine("No");
return;
}
Console.WriteLine("Yes");
}
Console.WriteLine("No");
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string ABC = Console.ReadLine();
string[] split = ABC.Split();
int A = int.Parse(split[0]);
int B = int.Parse(split[1]);
int C = int.Parse(split[2]);
if (A == B || A == C || B == C) {
if (A == B && B == C) {
Console.WriteLine("No");
return;
}
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35]]
| 8
| 141
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;
namespace AtCoderWorkspace {
public class Solver {
public void Solve() {
var cin = new Scanner();
var a = cin.nextInt();
var b = cin.nextInt();
var c = cin.nextInt();
var f = false;
if (a == b && a != c) {
Console.WriteLine("Yes");
return;
}
if (a == c && a != b) {
Console.WriteLine("Yes");
return;
}
if (b == c && b != c) {
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public int[] DPArrayInt(int N, int ex) {
int[] Array = new int[N + ex];
for (int i = 0; i < N; i++) {
Array[i] = nextInt();
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public long[] DPArrayLong(int N, int ex) {
long[] Array = new long[N + ex];
for (int i = 0; i < N; i++) {
Array[i] = nextLong();
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] s) => new Solver().Solve();
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;
namespace AtCoderWorkspace {
public class Solver {
public void Solve() {
var cin = new Scanner();
var a = cin.nextInt();
var b = cin.nextInt();
var c = cin.nextInt();
var f = false;
if (a == b && a != c) {
Console.WriteLine("Yes");
return;
}
if (a == c && a != b) {
Console.WriteLine("Yes");
return;
}
if (b == c && b != a) {
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public int[] DPArrayInt(int N, int ex) {
int[] Array = new int[N + ex];
for (int i = 0; i < N; i++) {
Array[i] = nextInt();
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public long[] DPArrayLong(int N, int ex) {
long[] Array = new long[N + ex];
for (int i = 0; i < N; i++) {
Array[i] = nextLong();
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] s) => new Solver().Solve();
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 649
| 2
|
using System;
using System.Linq;
namespace ABC155A {
class Program {
static void Main(string[] args) {
var ABC = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
Console.WriteLine(ABC.Distinct().Count() == 1 ? "No" : "Yes");
}
}
}
|
using System;
using System.Linq;
namespace ABC155A {
class Program {
static void Main(string[] args) {
var ABC = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
Console.WriteLine(ABC.Distinct().Count() == 2 ? "Yes" : "No");
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 81
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
// https://atcoder.jp/contests/abc155/tasks/abc155_a
public class QuestionA {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long a = inputLongArray[0];
long b = inputLongArray[1];
long c = inputLongArray[2];
if (a == b) {
if (b == c) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
} else {
if (b == c && a != c) {
Console.WriteLine("Yes");
}
if (b != c && a == c) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
// https://atcoder.jp/contests/abc155/tasks/abc155_a
public class QuestionA {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long a = inputLongArray[0];
long b = inputLongArray[1];
long c = inputLongArray[2];
if (a == b) {
if (b == c) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
} else {
if (b == c && a != c) {
Console.WriteLine("Yes");
} else if (b != c && a == c) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
Console.Out.Flush();
}
}
}
|
[["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 95]]
| 8
| 238
| 1
|
using System;
namespace AtCoder {
class Program {
static void Main() {
int N = int.Parse(Console.ReadLine());
string[] n = Console.ReadLine().Split();
int[] a = new int[N];
for (int x = 0; x < N; x++) {
a[x] = int.Parse(n[x]);
}
for (int y = 0; y < N; y++) {
if (a[y] % 2 == 0) {
if (a[y] % 5 == 0 && a[y] % 3 == 0) {
} else {
Console.WriteLine("DENIED");
y = N;
}
}
if (y == N - 1) {
Console.WriteLine("APPROVED");
}
}
}
}
}
|
using System;
namespace AtCoder {
class Program {
static void Main() {
int N = int.Parse(Console.ReadLine());
string[] n = Console.ReadLine().Split();
int[] a = new int[N];
for (int x = 0; x < N; x++) {
a[x] = int.Parse(n[x]);
}
for (int y = 0; y < N; y++) {
if (a[y] % 2 == 0) {
if (a[y] % 5 == 0 || a[y] % 3 == 0) {
} else {
Console.WriteLine("DENIED");
y = N;
}
}
if (y == N - 1) {
Console.WriteLine("APPROVED");
}
}
}
}
}
|
[["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 106]]
| 8
| 175
| 2
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
string s = "DENIED";
for (int i = 0; i < N; i++) {
if (A[i] % 2 == 0) {
if (A[i] % 3 == 0 || A[i] % 5 == 0) {
s = "APPROVED";
} else {
s = "DENIED";
break;
}
}
}
Console.WriteLine(s);
}
}
}
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
string s = "APPROVED";
for (int i = 0; i < N; i++) {
if (A[i] % 2 == 0) {
if (A[i] % 3 == 0 || A[i] % 5 == 0) {
s = "APPROVED";
} else {
s = "DENIED";
break;
}
}
}
Console.WriteLine(s);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222]]
| 8
| 157
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc155_b {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine()); // N個の書類
var As = Console.ReadLine().Split(' ');
for (int i = 0; i < As.Length; i++) {
var A = int.Parse(As[i]);
if (A % 2 == 0) //偶数で割れるか?
{
if (A % 3 == 0 || A % 5 == 0) // 3または5で割れるか?
{
Console.WriteLine("DENIED");
Console.Read();
return;
}
}
}
Console.WriteLine("APPROVED");
Console.Read();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc155_b {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine()); // N個の書類
var As = Console.ReadLine().Split(' ');
for (int i = 0; i < As.Length; i++) {
var A = int.Parse(As[i]);
if (A % 2 == 0) //偶数で割れるか?
{
if (!(A % 3 == 0 || A % 5 == 0)) // 3または5で割れるか?
{
Console.WriteLine("DENIED");
Console.Read();
return;
}
}
}
Console.WriteLine("APPROVED");
Console.Read();
}
}
}
|
[["+", 0, 57, 64, 196, 0, 57, 15, 241, 0, 111], ["+", 64, 196, 0, 57, 15, 241, 0, 23, 0, 24], ["+", 64, 196, 0, 57, 15, 241, 0, 23, 0, 25]]
| 8
| 168
| 3
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] ax =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int[] ax2 = ax.Where(w => w % 2 == 0).ToArray();
if (ax2.Length == 0) {
Console.WriteLine("DENIED");
return;
}
int[] ax3 = ax2.Where(w => w % 3 == 0 || w % 5 == 0).ToArray();
if (ax2.Length != ax3.Length) {
Console.WriteLine("DENIED");
return;
}
Console.WriteLine("APPROVED");
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] ax =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int[] ax2 = ax.Where(w => w % 2 == 0).ToArray();
if (ax2.Length == 0) {
Console.WriteLine("APPROVED");
return;
}
int[] ax3 = ax2.Where(w => w % 3 == 0 || w % 5 == 0).ToArray();
if (ax2.Length != ax3.Length) {
Console.WriteLine("DENIED");
return;
}
Console.WriteLine("APPROVED");
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 174
| 2
|
//==========================================c#
/* ===========================================
// null
//
//
=========================================== */
using System; // Console, IComparable
using System.IO; // StreamWriter
using System.Linq; // Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; // List<T>
class Program {
static void Main() {
StreamWriter so = new StreamWriter(Console.OpenStandardOutput());
string[] sip;
int[] iip;
var n = int.Parse(Console.ReadLine());
var chk = true;
iip = Console.ReadLine().Split(' ').Select(fd => int.Parse(fd)).ToArray();
for (int i = 0; i < n; i++) {
var a = iip[i];
if ((a & 1) == 0) {
if (a % 3 == 0 || a % 5 == 0) {
continue;
} else {
chk = false;
break;
}
} else {
chk = false;
break;
}
}
if (chk == true) {
Console.WriteLine("APPROVED");
} else {
Console.WriteLine("DENIED");
}
}
}
/* ===========================================
int n = int.Parse(Console.ReadLine());
for(int i = 0; i < n; i++){
int sum = Console.ReadLine().Split().Select(int.Parse).Sum();
so.WriteLine(sum.ToString());
}
so.Close();
=========================================== */
|
//==========================================c#
/* ===========================================
// null
//
//
=========================================== */
using System; // Console, IComparable
using System.IO; // StreamWriter
using System.Linq; // Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; // List<T>
class Program {
static void Main() {
StreamWriter so = new StreamWriter(Console.OpenStandardOutput());
string[] sip;
int[] iip;
var n = int.Parse(Console.ReadLine());
var chk = true;
iip = Console.ReadLine().Split(' ').Select(fd => int.Parse(fd)).ToArray();
for (int i = 0; i < n; i++) {
var a = iip[i];
if ((a & 1) == 0) {
if (a % 3 == 0 || a % 5 == 0) {
continue;
} else {
chk = false;
break;
}
} else {
continue;
}
}
if (chk == true) {
Console.WriteLine("APPROVED");
} else {
Console.WriteLine("DENIED");
}
}
}
/* ===========================================
int n = int.Parse(Console.ReadLine());
for(int i = 0; i < n; i++){
int sum = Console.ReadLine().Split().Select(int.Parse).Sum();
so.WriteLine(sum.ToString());
}
so.Close();
=========================================== */
|
[["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 75, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 75, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 75, 196, 0, 116, 0, 117]]
| 8
| 212
| 6
|
using System;
public class Hello {
public static void Main() {
var times = int.Parse(Console.ReadLine());
var input = Console.ReadLine().Split(' ');
var result = "DENIED";
for (var i = 0; i < times; i++) {
if (int.Parse(input[i]) % 2 == 0) {
if (int.Parse(input[i]) % 3 == 0 || int.Parse(input[i]) % 5 == 0) {
result = "APPROVED";
} else {
result = "DENIED";
break;
}
}
}
Console.WriteLine(result);
}
}
|
using System;
public class Hello {
public static void Main() {
var times = int.Parse(Console.ReadLine());
var input = Console.ReadLine().Split(' ');
var result = "APPROVED";
for (var i = 0; i < times; i++) {
if (int.Parse(input[i]) % 2 == 0) {
if (int.Parse(input[i]) % 3 == 0 || int.Parse(input[i]) % 5 == 0) {
result = "APPROVED";
} else {
result = "DENIED";
break;
}
}
}
Console.WriteLine(result);
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222]]
| 8
| 143
| 2
|
using System;
namespace AtCoderCs {
class Program {
static void Main(string[] args) {
var num = int.Parse(Console.ReadLine());
var str = Console.ReadLine().Split(' ');
foreach (var @int in str) {
int c = int.Parse(@int);
if (c % 2 == 0 && c % 3 != 0 && c % 5 != 0)
Console.WriteLine("DENIED");
return;
}
Console.WriteLine("APPROVED");
return;
}
}
}
|
using System;
namespace AtCoderCs {
class Program {
static void Main(string[] args) {
var num = int.Parse(Console.ReadLine());
var str = Console.ReadLine().Split(' ');
foreach (var @int in str) {
int c = int.Parse(@int);
if (c % 2 == 0 && c % 3 != 0 && c % 5 != 0) {
Console.WriteLine("DENIED");
return;
}
}
Console.WriteLine("APPROVED");
return;
}
}
}
|
[["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 113
| 2
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
class Program {
static void Main() {
FastScanner sc = new FastScanner(Console.OpenStandardInput());
int N = sc.nextInt();
int[] A = sc.intArray(N);
bool flg = true;
for (int i = 0; i < N; i++) {
if (A[i] / 2 == 0 && A[i] % 3 == 1 && A[i] % 5 == 1) {
flg = false;
break;
}
}
Console.WriteLine(flg ? "APPROVED" : "DENIED");
}
}
// FastScanner start
public class FastScanner {
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public FastScanner(Stream stream) { str = stream; }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char nextChar() {
byte b = 0;
do {
b = read();
} while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public int nextInt() { return (isEof) ? int.MinValue : (int)nextLong(); }
public long nextLong() {
if (isEof) {
return long.MinValue;
}
long ret = 0;
byte b = 0;
var ng = false;
do {
b = read();
} while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b) {
return ng ? -ret : ret;
} else
ret = ret * 10 + b - '0';
}
}
public int[] intArray(int n) { return enumerate(n, nextInt); }
public long[] longArray(int n) { return enumerate(n, nextLong); }
public char[] charArray(int n) { return enumerate(n, nextChar); }
public string Scan() {
var sb = new StringBuilder();
for (var b = nextChar(); b >= 33 && b <= 126; b = (char)read()) {
sb.Append(b);
}
return sb.ToString();
}
private byte read() {
if (isEof) {
return 0;
}
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
}
// FastScanner end
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
class Program {
static void Main() {
FastScanner sc = new FastScanner(Console.OpenStandardInput());
int N = sc.nextInt();
int[] A = sc.intArray(N);
bool flg = true;
for (int i = 0; i < N; i++) {
if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
flg = false;
break;
}
}
Console.WriteLine(flg ? "APPROVED" : "DENIED");
}
}
// FastScanner start
public class FastScanner {
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public FastScanner(Stream stream) { str = stream; }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char nextChar() {
byte b = 0;
do {
b = read();
} while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public int nextInt() { return (isEof) ? int.MinValue : (int)nextLong(); }
public long nextLong() {
if (isEof) {
return long.MinValue;
}
long ret = 0;
byte b = 0;
var ng = false;
do {
b = read();
} while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b) {
return ng ? -ret : ret;
} else
ret = ret * 10 + b - '0';
}
}
public int[] intArray(int n) { return enumerate(n, nextInt); }
public long[] longArray(int n) { return enumerate(n, nextLong); }
public char[] charArray(int n) { return enumerate(n, nextChar); }
public string Scan() {
var sb = new StringBuilder();
for (var b = nextChar(); b >= 33 && b <= 126; b = (char)read()) {
sb.Append(b);
}
return sb.ToString();
}
private byte read() {
if (isEof) {
return 0;
}
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
}
// FastScanner end
|
[["-", 15, 16, 31, 16, 31, 16, 31, 16, 17, 85], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 17, 109], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 60], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 630
| 10
|
using System;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main(string[] args) {
int N = int.Parse(ReadLine());
bool b = false;
int[] A = new int[N];
string[] str = ReadLine().Split(' ');
for (int i = 0; i < N; i++)
A[i] = int.Parse(str[i]);
for (int i = 0; i < N; i++) {
if (A[i] % 2 == 0) {
if (A[i] % 3 == 0 || A[i] % 5 == 0)
b = true;
else {
b = false;
break;
}
}
}
if (b)
WriteLine("APPROVED");
else
WriteLine("DENIED");
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main(string[] args) {
int N = int.Parse(ReadLine());
bool b = true;
int[] A = new int[N];
string[] str = ReadLine().Split(' ');
for (int i = 0; i < N; i++)
A[i] = int.Parse(str[i]);
for (int i = 0; i < N; i++) {
if (A[i] % 2 == 0) {
if (A[i] % 3 == 0 || A[i] % 5 == 0)
b = true;
else {
b = false;
break;
}
}
}
if (b)
WriteLine("APPROVED");
else
WriteLine("DENIED");
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146]]
| 8
| 190
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace PapersPlease {
class Program {
static void Main(string[] args) {
var ninput = int.Parse(Console.ReadLine());
var inputs = Console.ReadLine().Split(' ');
int[] inputArray = Array.ConvertAll(inputs, x => int.Parse(x));
List<int> evenArray = new List<int>();
for (int i = 0; i < inputArray.Count(); i++) {
if (inputArray[i] % 2 == 0) {
evenArray.Add(inputArray[i]);
}
}
evenArray.RemoveAll(x => x.Equals(0));
List<int> newArray = new List<int>();
for (int i = 0; i < evenArray.Count(); i++) {
if (evenArray[i] % 3 == 0) {
newArray.Add(evenArray[i]);
}
if (evenArray[i] % 5 == 0) {
newArray.Add(evenArray[i]);
}
}
if (evenArray.Count() == newArray.Count()) {
Console.WriteLine("APPROVED");
} else {
Console.WriteLine("DENIED");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace PapersPlease {
class Program {
static void Main(string[] args) {
var ninput = int.Parse(Console.ReadLine());
var inputs = Console.ReadLine().Split(' ');
int[] inputArray = Array.ConvertAll(inputs, x => int.Parse(x));
List<int> evenArray = new List<int>();
for (int i = 0; i < inputArray.Count(); i++) {
if (inputArray[i] % 2 == 0) {
evenArray.Add(inputArray[i]);
}
}
evenArray.RemoveAll(x => x.Equals(0));
List<int> newArray = new List<int>();
for (int i = 0; i < evenArray.Count(); i++) {
if (evenArray[i] % 3 == 0) {
newArray.Add(evenArray[i]);
}
else if (evenArray[i] % 5 == 0) {
newArray.Add(evenArray[i]);
}
}
if (evenArray.Count() == newArray.Count()) {
Console.WriteLine("APPROVED");
} else {
Console.WriteLine("DENIED");
}
}
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95]]
| 8
| 273
| 1
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC157B {
class Program {
static void Main(string[] args) {
int[,] A = new int[3, 3];
for (int i = 0; i < 3; i++) {
string[] input = Console.ReadLine().Split(' ');
A[i, 0] = int.Parse(input[0]);
A[i, 1] = int.Parse(input[1]);
A[i, 2] = int.Parse(input[1]);
}
int N = int.Parse(Console.ReadLine());
int[] b = new int[N];
for (int i = 0; i < N; i++) {
b[i] = int.Parse(Console.ReadLine());
}
bool[,] bingo = new bool[3, 3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (b.Contains(A[i, j]) == true) {
bingo[i, j] = true;
}
}
}
bool hantei = false;
if (bingo[0, 0] == true & bingo[0, 1] == true & bingo[0, 2] == true) {
hantei = true;
} else if (bingo[1, 0] == true & bingo[1, 1] == true &
bingo[1, 2] == true) {
hantei = true;
} else if (bingo[2, 0] == true & bingo[2, 1] == true &
bingo[2, 2] == true) {
hantei = true;
} else if (bingo[0, 0] == true & bingo[1, 0] == true &
bingo[2, 0] == true) {
hantei = true;
} else if (bingo[0, 1] == true & bingo[1, 1] == true &
bingo[2, 1] == true) {
hantei = true;
} else if (bingo[0, 2] == true & bingo[1, 2] == true &
bingo[2, 2] == true) {
hantei = true;
} else if (bingo[0, 0] == true & bingo[1, 1] == true &
bingo[2, 2] == true) {
hantei = true;
} else if (bingo[2, 0] == true & bingo[1, 1] == true &
bingo[0, 2] == true) {
hantei = true;
}
if (hantei == true) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC157B {
class Program {
static void Main(string[] args) {
int[,] A = new int[3, 3];
for (int i = 0; i < 3; i++) {
string[] input = Console.ReadLine().Split(' ');
A[i, 0] = int.Parse(input[0]);
A[i, 1] = int.Parse(input[1]);
A[i, 2] = int.Parse(input[2]);
}
int N = int.Parse(Console.ReadLine());
int[] b = new int[N];
for (int i = 0; i < N; i++) {
b[i] = int.Parse(Console.ReadLine());
}
bool[,] bingo = new bool[3, 3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (b.Contains(A[i, j]) == true) {
bingo[i, j] = true;
}
}
}
bool hantei = false;
if (bingo[0, 0] == true & bingo[0, 1] == true & bingo[0, 2] == true) {
hantei = true;
} else if (bingo[1, 0] == true & bingo[1, 1] == true &
bingo[1, 2] == true) {
hantei = true;
} else if (bingo[2, 0] == true & bingo[2, 1] == true &
bingo[2, 2] == true) {
hantei = true;
} else if (bingo[0, 0] == true & bingo[1, 0] == true &
bingo[2, 0] == true) {
hantei = true;
} else if (bingo[0, 1] == true & bingo[1, 1] == true &
bingo[2, 1] == true) {
hantei = true;
} else if (bingo[0, 2] == true & bingo[1, 2] == true &
bingo[2, 2] == true) {
hantei = true;
} else if (bingo[0, 0] == true & bingo[1, 1] == true &
bingo[2, 2] == true) {
hantei = true;
} else if (bingo[2, 0] == true & bingo[1, 1] == true &
bingo[0, 2] == true) {
hantei = true;
}
if (hantei == true) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 596
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
var board = new string[3, 3];
var n = 0;
for (var i = 0; i < 3; i++) {
var x = ReadLine().Split(' ');
for (var j = 0; j < 3; j++) {
board[i, j] = x[j];
}
}
n = int.Parse(ReadLine());
for (var i = 0; i < n; i++) {
var x = ReadLine();
for (var j = 0; j < 3; j++) {
for (var k = 0; k < 3; k++) {
if (board[j, k].Equals(x)) {
board[j, k] = "101";
}
}
}
}
for (var i = 0; i < 3; i++) {
var x = new string[3];
var y = new string[3];
for (var j = 0; j < 3; j++) {
x[j] = board[i, j];
y[j] = board[j, i];
}
if (x.All(a => a.Equals("101"))) {
Write("Yes");
return;
} else if (y.All(b => b.Equals("101"))) {
Write("Yes");
return;
}
}
var s = new string[3];
var t = new string[3];
int o, p;
for (o = 0, p = 2; o < 3; o++, p--) {
s[o] = board[o, p];
t[o] = board[p, o];
}
if (s.All(a => a.Equals("101"))) {
Write("Yes");
return;
} else if (t.All(b => b.Equals("101"))) {
Write("Yes");
return;
}
Write("No");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
var board = new string[3, 3];
var n = 0;
for (var i = 0; i < 3; i++) {
var x = ReadLine().Split(' ');
for (var j = 0; j < 3; j++) {
board[i, j] = x[j];
}
}
n = int.Parse(ReadLine());
for (var i = 0; i < n; i++) {
var x = ReadLine();
for (var j = 0; j < 3; j++) {
for (var k = 0; k < 3; k++) {
if (board[j, k].Equals(x)) {
board[j, k] = "101";
}
}
}
}
for (var i = 0; i < 3; i++) {
var x = new string[3];
var y = new string[3];
for (var j = 0; j < 3; j++) {
x[j] = board[i, j];
y[j] = board[j, i];
}
if (x.All(a => a.Equals("101"))) {
Write("Yes");
return;
} else if (y.All(b => b.Equals("101"))) {
Write("Yes");
return;
}
}
var s = new string[3];
var t = new string[3];
int o, p;
for (o = 0, p = 2; o < 3; o++, p--) {
s[o] = board[o, p];
t[o] = board[p, p];
}
if (s.All(a => a.Equals("101"))) {
Write("Yes");
return;
} else if (t.All(b => b.Equals("101"))) {
Write("Yes");
return;
}
Write("No");
}
}
|
[["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22]]
| 8
| 467
| 2
|
using System;
namespace AtCoderSucks {
internal static class Program {
private static void Main(string[] args) {
int[] A1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] A2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] A3 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int N = int.Parse(Console.ReadLine());
bool[,] P = new bool[,] {
{ false, false, false },
{ false, false, false },
{ false, false, false },
};
for (int i = 0; i < N; i++) {
int B = int.Parse(Console.ReadLine());
for (int j = 0; j < 3; j++) {
if (B == A1[j])
P[0, j] = true;
}
for (int j = 0; j < 3; j++) {
if (B == A2[j])
P[1, j] = true;
}
for (int j = 0; j < 3; j++) {
if (B == A3[j])
P[2, j] = true;
}
}
bool bingo = false;
for (int i = 0; i < 3; i++) {
if (P[i, 0] && P[i, 2] && P[i, 3]) {
bingo = true;
}
}
for (int i = 0; i < 3; i++) {
if (P[0, i] && P[1, i] && P[2, i]) {
bingo = true;
}
}
if (P[0, 0] && P[1, 1] && P[2, 2])
bingo = true;
if (P[0, 2] && P[1, 1] && P[2, 0])
bingo = true;
if (bingo)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
namespace AtCoderSucks {
internal static class Program {
private static void Main(string[] args) {
int[] A1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] A2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] A3 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int N = int.Parse(Console.ReadLine());
bool[,] P = new bool[,] {
{ false, false, false },
{ false, false, false },
{ false, false, false },
};
for (int i = 0; i < N; i++) {
int B = int.Parse(Console.ReadLine());
for (int j = 0; j < 3; j++) {
if (B == A1[j])
P[0, j] = true;
}
for (int j = 0; j < 3; j++) {
if (B == A2[j])
P[1, j] = true;
}
for (int j = 0; j < 3; j++) {
if (B == A3[j])
P[2, j] = true;
}
}
bool bingo = false;
for (int i = 0; i < 3; i++) {
if (P[i, 0] && P[i, 1] && P[i, 2]) {
bingo = true;
}
}
for (int i = 0; i < 3; i++) {
if (P[0, i] && P[1, i] && P[2, i]) {
bingo = true;
}
}
if (P[0, 0] && P[1, 1] && P[2, 2])
bingo = true;
if (P[0, 2] && P[1, 1] && P[2, 0])
bingo = true;
if (bingo)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 453
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static void Main(string[] args) {
try {
Solve.Answer();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var a1 = IO.ReadSplitInt;
var a2 = IO.ReadSplitInt;
var a3 = IO.ReadSplitInt;
bool[] b1 = new bool[3];
bool[] b2 = new bool[3];
bool[] b3 = new bool[3];
var n = IO.ReadInt;
for (int i = 0; i < n; i++) {
var num = IO.ReadInt;
d(a1, ref b1, num);
d(a1, ref b2, num);
d(a1, ref b3, num);
}
bool f = false;
if (b1[0] == true && b2[0] == true && b3[0] == true)
f = true;
if (b1[1] == true && b2[1] == true && b3[1] == true)
f = true;
if (b1[2] == true && b2[2] == true && b3[2] == true)
f = true;
if (b1[0] == true && b1[1] == true && b1[2] == true)
f = true;
if (b2[0] == true && b2[1] == true && b2[2] == true)
f = true;
if (b3[0] == true && b3[1] == true && b3[2] == true)
f = true;
if (b1[0] == true && b2[1] == true && b3[2] == true)
f = true;
if (b1[2] == true && b2[1] == true && b3[0] == true)
f = true;
IO.WriteLineYes_or_No(f);
}
public static void d(List<int> a, ref bool[] b, int n) {
for (int i = 0; i < a.Count; i++) {
if (a[i] == n)
b[i] = true;
}
}
public class IO {
#region Input
public static string ReadString => ReadLine();
public static int ReadInt => int.Parse(ReadLine());
public static long ReadLong => long.Parse(ReadLine());
public static double ReadDouble => double.Parse(ReadLine());
public static List<string> ReadSplitString => ReadLine().Split().ToList();
public static List<int> ReadSplitInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToList();
public static List<long> ReadSplitLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToList();
public static List<double> ReadSplitdouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToList();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
#endregion
}
/// <summary>
/// 正の数の四則演算のみ対応
/// </summary>
public class Mod {
// 割る数の定義
private readonly static long M = 1000000007;
// 足し算
public static long Add(long a, long b) => (a * b) % M;
// 引き算
public static long Sub(long a, long b) => (a - b) % M >= 0
? (a - b) % M
: (a - b) % M + M;
// 掛け算
public static long Multi(long a, long b) => (a * b) % M;
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
// public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
// public int[] ArrInt1D(int n) => Create(n, () => Int);
// public long[] ArrLong1D(int n) => Create(n, () => Long);
// public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
// public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
// インライン化を推奨する
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
}
public static long GCD(long x, long y) {
if (x < y) {
var tmp = x;
x = y;
y = tmp;
}
while (true)
{
if (x % y == 0) {
return y;
} else {
var tmp = x;
x = y;
y = tmp % y;
}
}
}
}
public class Combination {
public static long Choice2(long n) {
if (n <= 1)
return 0;
if (n == 2)
return 1;
else
return n * (n - 1) / 2;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static void Main(string[] args) {
try {
Solve.Answer();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var a1 = IO.ReadSplitInt;
var a2 = IO.ReadSplitInt;
var a3 = IO.ReadSplitInt;
bool[] b1 = new bool[3];
bool[] b2 = new bool[3];
bool[] b3 = new bool[3];
var n = IO.ReadInt;
for (int i = 0; i < n; i++) {
var num = IO.ReadInt;
d(a1, ref b1, num);
d(a2, ref b2, num);
d(a3, ref b3, num);
}
bool f = false;
if (b1[0] == true && b2[0] == true && b3[0] == true)
f = true;
if (b1[1] == true && b2[1] == true && b3[1] == true)
f = true;
if (b1[2] == true && b2[2] == true && b3[2] == true)
f = true;
if (b1[0] == true && b1[1] == true && b1[2] == true)
f = true;
if (b2[0] == true && b2[1] == true && b2[2] == true)
f = true;
if (b3[0] == true && b3[1] == true && b3[2] == true)
f = true;
if (b1[0] == true && b2[1] == true && b3[2] == true)
f = true;
if (b1[2] == true && b2[1] == true && b3[0] == true)
f = true;
IO.WriteLineYes_or_No(f);
}
public static void d(List<int> a, ref bool[] b, int n) {
for (int i = 0; i < a.Count; i++) {
if (a[i] == n)
b[i] = true;
}
}
public class IO {
#region Input
public static string ReadString => ReadLine();
public static int ReadInt => int.Parse(ReadLine());
public static long ReadLong => long.Parse(ReadLine());
public static double ReadDouble => double.Parse(ReadLine());
public static List<string> ReadSplitString => ReadLine().Split().ToList();
public static List<int> ReadSplitInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToList();
public static List<long> ReadSplitLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToList();
public static List<double> ReadSplitdouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToList();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
#endregion
}
/// <summary>
/// 正の数の四則演算のみ対応
/// </summary>
public class Mod {
// 割る数の定義
private readonly static long M = 1000000007;
// 足し算
public static long Add(long a, long b) => (a * b) % M;
// 引き算
public static long Sub(long a, long b) => (a - b) % M >= 0
? (a - b) % M
: (a - b) % M + M;
// 掛け算
public static long Multi(long a, long b) => (a * b) % M;
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
// public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
// public int[] ArrInt1D(int n) => Create(n, () => Int);
// public long[] ArrLong1D(int n) => Create(n, () => Long);
// public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
// public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
// インライン化を推奨する
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
}
public static long GCD(long x, long y) {
if (x < y) {
var tmp = x;
x = y;
y = tmp;
}
while (true)
{
if (x % y == 0) {
return y;
} else {
var tmp = x;
x = y;
y = tmp % y;
}
}
}
}
public class Combination {
public static long Choice2(long n) {
if (n <= 1)
return 0;
if (n == 2)
return 1;
else
return n * (n - 1) / 2;
}
}
}
|
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 1,419
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Math;
using static ABC156.Cin;
using static ABC156.Util;
using Pair = ABC156.VTuple<long, long>;
using Graph =
System.Collections.Generic.List<System.Collections.Generic.List<long>>;
namespace ABC156 {
public class Program {
static void Main(string[] args) { Abc157_B(); }
public static void Abc157_F() {}
public static void Abc157_E() {}
public static void Abc157_D() {}
public static void Abc157_C() {}
public static void Abc157_B() {
long[][] a = ReadLongTable(3);
long n = rl;
HashSet<long> hs = new HashSet<long>();
for (int i = 0; i < n; i++) {
hs.Add(rl);
}
for (int i = 0; i < 3; i++) {
bool b = true;
for (int j = 0; j < 3; j++) {
b = b && hs.Contains(a[i][j]);
}
if (b) {
Console.WriteLine("Yes");
return;
}
}
for (int i = 0; i < 3; i++) {
bool b = true;
for (int j = 0; j < 3; j++) {
b = b && hs.Contains(a[j][i]);
}
if (b) {
Console.WriteLine("Yes");
return;
}
}
bool c = true;
for (int j = 0; j < 3; j++) {
c = c && hs.Contains(a[j][j]);
}
if (c) {
Console.WriteLine("Yes");
return;
}
c = true;
for (int j = 0; j < 3; j++) {
c = c && hs.Contains(a[2 - j][2 - j]);
}
if (c) {
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
public static void Abc157_A() {
long N = rl;
Console.WriteLine((N + 1) / 2);
}
}
public struct Mint {
public static long MOD = (long)1e9 + 7;
/// <summary>
/// 0以上MOD未満の整数
/// </summary>
public long Value;
public Mint(long val) {
Value = val % MOD;
if (Value < 0)
Value += MOD;
}
private static Mint Ctor(long val) { return new Mint() { Value = val }; }
public static Mint operator +(Mint a, Mint b) {
long res = a.Value + b.Value;
if (res > MOD)
res -= MOD;
return Ctor(res);
}
public static Mint operator -(Mint a, Mint b) {
long res = a.Value - b.Value;
if (res < 0)
res += MOD;
return Ctor(res);
}
public static Mint operator *(Mint a, Mint b) {
long res = a.Value * b.Value;
if (res > MOD)
res %= MOD;
return Ctor(res);
}
public static Mint operator /(Mint a, Mint b) { return a * Inv(b); }
public static Mint Pow(Mint a, long n) {
if (n == 0)
return new Mint(1);
Mint b = Pow(a, n >> 1);
b *= b;
if ((n & 1) == 1)
b *= a;
return b;
}
public static Mint Inv(Mint n) {
long a = n.Value;
long b = MOD;
long x = 1;
long u = 0;
while (b != 0) {
long k = a / b;
long _x = u;
u = x - k * u;
x = _x;
long _a = a;
a = b;
b = _a - (k * b);
}
return new Mint(x);
}
public override string ToString() { return Value.ToString(); }
public static implicit operator Mint(long a) { return new Mint(a); }
public static explicit operator long(Mint a) { return a.Value; }
}
public class HashMap<K, V> : Dictionary<K, V> {
V i;
static Func<V> j =
System.Linq.Expressions.Expression
.Lambda<Func<V>>(System.Linq.Expressions.Expression.New(typeof(V)))
.Compile();
public HashMap() {}
public HashMap(V a) { i = a; }
new public V this[K a] { get { V b;
if (TryGetValue(a, out b))
return b;
else
return base[a] = i != null ? i : j();
}
set { base[a] = value; }
}
}
public static class Util {
public static readonly long INF = (long)1e17;
public readonly static long MOD = (long)1e9 + 7;
public static void DontAutoFlush() {
var a = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(a);
}
public static void Flush() { Console.Out.Flush(); }
public static T[] Sort<T>(T[] a) {
Array.Sort<T>(a);
return a;
}
public static T[] SortDecend<T>(T[] a) {
Array.Sort<T>(a);
Array.Reverse(a);
return a;
}
public static void Swap<T>(ref T a, ref T b) {
T c = a;
a = b;
b = c;
}
public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); }
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public static long ModAdd(long a, long b) {
long c = a + b;
if (c >= MOD)
return c % MOD;
return c;
}
public static long ModMul(long a, long b) {
long c = a * b;
if (c >= MOD)
return c % MOD;
return c;
}
public static void ChModAdd(ref long a, long b) {
a += b;
if (a >= MOD)
a %= MOD;
}
public static void ChModMul(ref long a, long b) {
a *= b;
if (a >= MOD)
a %= MOD;
}
public static void FillArray<T>(T[] a, T b) {
int c = a.Length;
for (int d = 0; d < c; d++)
a[d] = b;
}
public static void FillArray<T>(T[,] a, T b) {
int c = a.GetLength(0);
int d = a.GetLength(1);
for (int e = 0; e < c; e++)
for (int f = 0; f < d; f++) {
a[e, f] = b;
}
}
public static void FillArray<T>(T[,,] a, T b) {
int c = a.GetLength(0);
int d = a.GetLength(1);
int e = a.GetLength(2);
for (int f = 0; f < c; f++)
for (int g = 0; g < d; g++) {
for (int h = 0; h < e; h++) {
a[f, g, h] = b;
}
}
}
public static long[] Accumulate(long[] a) {
long[] b = new long[a.Length + 1];
for (int c = 0; c < a.Length; c++)
b[c + 1] = b[c] + a[c];
return b;
}
public static double[] Accumulate(double[] a) {
double[] b = new double[a.Length + 1];
for (int c = 0; c < a.Length; c++)
b[c + 1] = b[c] + a[c];
return b;
}
}
public static class Cin {
public static long rl {
get { return ReadLong(); }
}
public static long[] rla {
get { return ReadLongArray(); }
}
public static double rd {
get { return ReadDouble(); }
}
public static double[] rda {
get { return ReadDoubleArray(); }
}
public static string rs {
get { return ReadString(); }
}
public static int ReadInt() { return int.Parse(k()); }
public static long ReadLong() { return long.Parse(k()); }
public static double ReadDouble() { return double.Parse(k()); }
public static string ReadString() { return k(); }
public static int[] ReadIntArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static double[] ReadDoubleArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
}
public static void ReadCols(out long[] a, out long[] b, long c) {
a = new long[c];
b = new long[c];
for (int d = 0; d < c; d++) {
a[d] = ReadLong();
b[d] = ReadLong();
}
}
public static void ReadCols(out long[] a, out long[] b, out long[] c,
long d) {
a = new long[d];
b = new long[d];
c = new long[d];
for (int e = 0; e < d; e++) {
a[e] = ReadLong();
b[e] = ReadLong();
c[e] = ReadLong();
}
}
public static int[][] ReadIntTable(int a) {
i = null;
int[][] b = new int [a][];
for (int c = 0; c < a; c++)
b[c] = ReadIntArray();
return b;
}
public static long[][] ReadLongTable(long a) {
i = null;
long[][] b = new long [a][];
for (long c = 0; c < a; c++)
b[c] = ReadLongArray();
return b;
}
static string[] i { get; set; }
static int j { get; set; }
static string k() {
if (i == null || i.Length <= j) {
i = Console.ReadLine().Split(' ');
j = 0;
}
return i[j++];
}
}
public struct VTuple<T1, T2> : IComparable<VTuple<T1, T2>>,
IEquatable<VTuple<T1, T2>> {
public T1 First;
public T2 Second;
public VTuple(T1 a, T2 b) {
First = a;
Second = b;
}
public int CompareTo(VTuple<T1, T2> a) {
int b = Comparer<T1>.Default.Compare(First, a.First);
if (b != 0)
return b;
return Comparer<T2>.Default.Compare(Second, a.Second);
}
public override bool Equals(object a) {
return a is VTuple<T1, T2> && Equals((VTuple<T1, T2>)a);
}
public bool Equals(VTuple<T1, T2> a) {
return EqualityComparer<T1>.Default.Equals(First, a.First) &&
EqualityComparer<T2>.Default.Equals(Second, a.Second);
}
public override int GetHashCode() {
int a = First != null ? First.GetHashCode() : 0;
int b = Second != null ? Second.GetHashCode() : 0;
uint c = ((uint)a << 5) | ((uint)a >> 27);
return ((int)c + a) ^ b;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Math;
using static ABC156.Cin;
using static ABC156.Util;
using Pair = ABC156.VTuple<long, long>;
using Graph =
System.Collections.Generic.List<System.Collections.Generic.List<long>>;
namespace ABC156 {
public class Program {
static void Main(string[] args) { Abc157_B(); }
public static void Abc157_F() {}
public static void Abc157_E() {}
public static void Abc157_D() {}
public static void Abc157_C() {}
public static void Abc157_B() {
long[][] a = ReadLongTable(3);
long n = rl;
HashSet<long> hs = new HashSet<long>();
for (int i = 0; i < n; i++) {
hs.Add(rl);
}
for (int i = 0; i < 3; i++) {
bool b = true;
for (int j = 0; j < 3; j++) {
b = b && hs.Contains(a[i][j]);
}
if (b) {
Console.WriteLine("Yes");
return;
}
}
for (int i = 0; i < 3; i++) {
bool b = true;
for (int j = 0; j < 3; j++) {
b = b && hs.Contains(a[j][i]);
}
if (b) {
Console.WriteLine("Yes");
return;
}
}
bool c = true;
for (int j = 0; j < 3; j++) {
c = c && hs.Contains(a[j][j]);
}
if (c) {
Console.WriteLine("Yes");
return;
}
c = true;
for (int j = 0; j < 3; j++) {
c = c && hs.Contains(a[2 - j][j]);
}
if (c) {
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
public static void Abc157_A() {
long N = rl;
Console.WriteLine((N + 1) / 2);
}
}
public struct Mint {
public static long MOD = (long)1e9 + 7;
/// <summary>
/// 0以上MOD未満の整数
/// </summary>
public long Value;
public Mint(long val) {
Value = val % MOD;
if (Value < 0)
Value += MOD;
}
private static Mint Ctor(long val) { return new Mint() { Value = val }; }
public static Mint operator +(Mint a, Mint b) {
long res = a.Value + b.Value;
if (res > MOD)
res -= MOD;
return Ctor(res);
}
public static Mint operator -(Mint a, Mint b) {
long res = a.Value - b.Value;
if (res < 0)
res += MOD;
return Ctor(res);
}
public static Mint operator *(Mint a, Mint b) {
long res = a.Value * b.Value;
if (res > MOD)
res %= MOD;
return Ctor(res);
}
public static Mint operator /(Mint a, Mint b) { return a * Inv(b); }
public static Mint Pow(Mint a, long n) {
if (n == 0)
return new Mint(1);
Mint b = Pow(a, n >> 1);
b *= b;
if ((n & 1) == 1)
b *= a;
return b;
}
public static Mint Inv(Mint n) {
long a = n.Value;
long b = MOD;
long x = 1;
long u = 0;
while (b != 0) {
long k = a / b;
long _x = u;
u = x - k * u;
x = _x;
long _a = a;
a = b;
b = _a - (k * b);
}
return new Mint(x);
}
public override string ToString() { return Value.ToString(); }
public static implicit operator Mint(long a) { return new Mint(a); }
public static explicit operator long(Mint a) { return a.Value; }
}
public class HashMap<K, V> : Dictionary<K, V> {
V i;
static Func<V> j =
System.Linq.Expressions.Expression
.Lambda<Func<V>>(System.Linq.Expressions.Expression.New(typeof(V)))
.Compile();
public HashMap() {}
public HashMap(V a) { i = a; }
new public V this[K a] { get { V b;
if (TryGetValue(a, out b))
return b;
else
return base[a] = i != null ? i : j();
}
set { base[a] = value; }
}
}
public static class Util {
public static readonly long INF = (long)1e17;
public readonly static long MOD = (long)1e9 + 7;
public static void DontAutoFlush() {
var a = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(a);
}
public static void Flush() { Console.Out.Flush(); }
public static T[] Sort<T>(T[] a) {
Array.Sort<T>(a);
return a;
}
public static T[] SortDecend<T>(T[] a) {
Array.Sort<T>(a);
Array.Reverse(a);
return a;
}
public static void Swap<T>(ref T a, ref T b) {
T c = a;
a = b;
b = c;
}
public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); }
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public static long ModAdd(long a, long b) {
long c = a + b;
if (c >= MOD)
return c % MOD;
return c;
}
public static long ModMul(long a, long b) {
long c = a * b;
if (c >= MOD)
return c % MOD;
return c;
}
public static void ChModAdd(ref long a, long b) {
a += b;
if (a >= MOD)
a %= MOD;
}
public static void ChModMul(ref long a, long b) {
a *= b;
if (a >= MOD)
a %= MOD;
}
public static void FillArray<T>(T[] a, T b) {
int c = a.Length;
for (int d = 0; d < c; d++)
a[d] = b;
}
public static void FillArray<T>(T[,] a, T b) {
int c = a.GetLength(0);
int d = a.GetLength(1);
for (int e = 0; e < c; e++)
for (int f = 0; f < d; f++) {
a[e, f] = b;
}
}
public static void FillArray<T>(T[,,] a, T b) {
int c = a.GetLength(0);
int d = a.GetLength(1);
int e = a.GetLength(2);
for (int f = 0; f < c; f++)
for (int g = 0; g < d; g++) {
for (int h = 0; h < e; h++) {
a[f, g, h] = b;
}
}
}
public static long[] Accumulate(long[] a) {
long[] b = new long[a.Length + 1];
for (int c = 0; c < a.Length; c++)
b[c + 1] = b[c] + a[c];
return b;
}
public static double[] Accumulate(double[] a) {
double[] b = new double[a.Length + 1];
for (int c = 0; c < a.Length; c++)
b[c + 1] = b[c] + a[c];
return b;
}
}
public static class Cin {
public static long rl {
get { return ReadLong(); }
}
public static long[] rla {
get { return ReadLongArray(); }
}
public static double rd {
get { return ReadDouble(); }
}
public static double[] rda {
get { return ReadDoubleArray(); }
}
public static string rs {
get { return ReadString(); }
}
public static int ReadInt() { return int.Parse(k()); }
public static long ReadLong() { return long.Parse(k()); }
public static double ReadDouble() { return double.Parse(k()); }
public static string ReadString() { return k(); }
public static int[] ReadIntArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static double[] ReadDoubleArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
}
public static void ReadCols(out long[] a, out long[] b, long c) {
a = new long[c];
b = new long[c];
for (int d = 0; d < c; d++) {
a[d] = ReadLong();
b[d] = ReadLong();
}
}
public static void ReadCols(out long[] a, out long[] b, out long[] c,
long d) {
a = new long[d];
b = new long[d];
c = new long[d];
for (int e = 0; e < d; e++) {
a[e] = ReadLong();
b[e] = ReadLong();
c[e] = ReadLong();
}
}
public static int[][] ReadIntTable(int a) {
i = null;
int[][] b = new int [a][];
for (int c = 0; c < a; c++)
b[c] = ReadIntArray();
return b;
}
public static long[][] ReadLongTable(long a) {
i = null;
long[][] b = new long [a][];
for (long c = 0; c < a; c++)
b[c] = ReadLongArray();
return b;
}
static string[] i { get; set; }
static int j { get; set; }
static string k() {
if (i == null || i.Length <= j) {
i = Console.ReadLine().Split(' ');
j = 0;
}
return i[j++];
}
}
public struct VTuple<T1, T2> : IComparable<VTuple<T1, T2>>,
IEquatable<VTuple<T1, T2>> {
public T1 First;
public T2 Second;
public VTuple(T1 a, T2 b) {
First = a;
Second = b;
}
public int CompareTo(VTuple<T1, T2> a) {
int b = Comparer<T1>.Default.Compare(First, a.First);
if (b != 0)
return b;
return Comparer<T2>.Default.Compare(Second, a.Second);
}
public override bool Equals(object a) {
return a is VTuple<T1, T2> && Equals((VTuple<T1, T2>)a);
}
public bool Equals(VTuple<T1, T2> a) {
return EqualityComparer<T1>.Default.Equals(First, a.First) &&
EqualityComparer<T2>.Default.Equals(Second, a.Second);
}
public override int GetHashCode() {
int a = First != null ? First.GetHashCode() : 0;
int b = Second != null ? Second.GetHashCode() : 0;
uint c = ((uint)a << 5) | ((uint)a >> 27);
return ((int)c + a) ^ b;
}
}
}
|
[["-", 0, 204, 206, 207, 0, 28, 0, 16, 31, 203], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33]]
| 8
| 2,653
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoders {
class Program {
static void Main(string[] args) {
var row1 = retreiveIntArray();
var row2 = retreiveIntArray();
var row3 = retreiveIntArray();
var inputCount = 3;
// 不正な入力は処理しない
if (row1.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
if (row2.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
if (row3.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
//列の正解を作る
var col1 = new int[] { row1[0], row2[0], row3[0] };
var col2 = new int[] { row1[1], row2[1], row3[1] };
var col3 = new int[] { row1[2], row2[2], row3[2] };
//斜めの正解を作る
var diagonal1 = new int[] { row1[0], row2[1], row3[2] };
var diagonal2 = new int[] { row1[2], row2[1], row3[0] };
var inputNums = retreiveInputNums();
//ビンゴになる正解のあつまり
int[][] bingos = { row1, row2, col1, col2, col3, diagonal1, diagonal2 };
var result = checkBingo(bingos, inputNums);
//答えの出力
var ans = result ? "Yes" : "No";
Console.WriteLine(ans);
}
private static bool checkBingo(int[][] bingos, int[] inputnums) {
foreach (var bingo in bingos) {
var result = bingo.Select(n => inputnums.Contains(n)).All(t => t);
//ビンゴになった時点で処理を止める
if (result) {
return true;
}
}
return false;
}
/// <summary>
/// 順番に与えられる数値を配列に格納する
/// </summary>
/// <returns></returns>
private static int[] retreiveInputNums() {
var N = int.Parse(Console.ReadLine());
var inputNums = new int[N];
for (int i = 0; i < N; i++) {
inputNums[i] = int.Parse(Console.ReadLine());
}
return inputNums;
}
/// <summary>
/// スペースで区切られた文字列配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static string[] retreiveStringArray() {
var inputArray = Console.ReadLine().Split(' ');
return inputArray;
}
/// <summary>
/// スペースで区切られた整数配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static int[] retreiveIntArray() {
var inputArray = Console.ReadLine().Split(' ');
var intArray = inputArray.Select(s => int.Parse(s));
return intArray.ToArray();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoders {
class Program {
static void Main(string[] args) {
var row1 = retreiveIntArray();
var row2 = retreiveIntArray();
var row3 = retreiveIntArray();
var inputCount = 3;
// 不正な入力は処理しない
if (row1.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
if (row2.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
if (row3.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
//列の正解を作る
var col1 = new int[] { row1[0], row2[0], row3[0] };
var col2 = new int[] { row1[1], row2[1], row3[1] };
var col3 = new int[] { row1[2], row2[2], row3[2] };
//斜めの正解を作る
var diagonal1 = new int[] { row1[0], row2[1], row3[2] };
var diagonal2 = new int[] { row1[2], row2[1], row3[0] };
var inputNums = retreiveInputNums();
//ビンゴになる正解のあつまり
int[][] bingos = { row1, row2, row3, col1,
col2, col3, diagonal1, diagonal2 };
var result = checkBingo(bingos, inputNums);
//答えの出力
var ans = result ? "Yes" : "No";
Console.WriteLine(ans);
}
private static bool checkBingo(int[][] bingos, int[] inputnums) {
foreach (var bingo in bingos) {
var result = bingo.Select(n => inputnums.Contains(n)).All(t => t);
//ビンゴになった時点で処理を止める
if (result) {
return true;
}
}
return false;
}
/// <summary>
/// 順番に与えられる数値を配列に格納する
/// </summary>
/// <returns></returns>
private static int[] retreiveInputNums() {
var N = int.Parse(Console.ReadLine());
var inputNums = new int[N];
for (int i = 0; i < N; i++) {
inputNums[i] = int.Parse(Console.ReadLine());
}
return inputNums;
}
/// <summary>
/// スペースで区切られた文字列配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static string[] retreiveStringArray() {
var inputArray = Console.ReadLine().Split(' ');
return inputArray;
}
/// <summary>
/// スペースで区切られた整数配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static int[] retreiveIntArray() {
var inputArray = Console.ReadLine().Split(' ');
var intArray = inputArray.Select(s => int.Parse(s));
return intArray.ToArray();
}
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 229, 0, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 229, 0, 21]]
| 8
| 544
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Program {
static void Main(string[] args) {
var card = new int[3, 3];
for (int i = 0; i < 3; i++) {
var r = Console.ReadLine().Split(' ');
for (int j = 0; j < r.Length; j++) {
card[i, j] = r[j].ToInt();
}
}
var N = Console.ReadLine().ToInt();
for (int i = 0; i < N; i++) {
var b = Console.ReadLine().ToInt();
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (card[j, k] == b) {
card[j, k] = 0;
break;
}
}
}
}
var ans = "No";
for (int i = 0; i < 3; i++) {
if (card[i, 0] + card[i, 1] + card[i, 2] == 0)
ans = "Yes";
break;
}
for (int i = 0; i < 3; i++) {
if (card[0, i] + card[1, i] + card[2, i] == 0)
ans = "Yes";
}
if (card[0, 0] + card[1, 1] + card[2, 2] == 0)
ans = "Yes";
if (card[0, 2] + card[1, 1] + card[2, 0] == 0)
ans = "Yes";
Console.WriteLine(ans);
}
}
public static class Extentions {
public static int ToInt(this object obj) { return int.Parse(obj.ToString()); }
public static decimal ToDecimal(this object obj) {
return decimal.Parse(obj.ToString());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Program {
static void Main(string[] args) {
var card = new int[3, 3];
for (int i = 0; i < 3; i++) {
var r = Console.ReadLine().Split(' ');
for (int j = 0; j < r.Length; j++) {
card[i, j] = r[j].ToInt();
}
}
var N = Console.ReadLine().ToInt();
for (int i = 0; i < N; i++) {
var b = Console.ReadLine().ToInt();
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (card[j, k] == b) {
card[j, k] = 0;
break;
}
}
}
}
var ans = "No";
for (int i = 0; i < 3; i++) {
if (card[i, 0] + card[i, 1] + card[i, 2] == 0)
ans = "Yes";
}
for (int i = 0; i < 3; i++) {
if (card[0, i] + card[1, i] + card[2, i] == 0)
ans = "Yes";
}
if (card[0, 0] + card[1, 1] + card[2, 2] == 0)
ans = "Yes";
if (card[0, 2] + card[1, 1] + card[2, 0] == 0)
ans = "Yes";
Console.WriteLine(ans);
}
}
public static class Extentions {
public static int ToInt(this object obj) { return int.Parse(obj.ToString()); }
public static decimal ToDecimal(this object obj) {
return decimal.Parse(obj.ToString());
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 93, 0, 94], ["-", 8, 196, 0, 7, 8, 196, 0, 93, 0, 35]]
| 8
| 445
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static bool bingo(bool[,] abool) {
for (int i = 0; i < 3; i++) {
var count = 0;
for (int j = 0; j < 3; j++) {
if (abool[i, j])
count++;
}
if (count == 3)
return true;
}
for (int i = 0; i < 3; i++) {
var count = 0;
for (int j = 0; j < 3; j++) {
if (abool[j, i])
count++;
}
if (count == 2)
return true;
}
var count0 = 0;
for (int i = 0; i < 3; i++) {
if (abool[i, i])
count0++;
}
if (count0 == 3)
return true;
var count1 = 0;
for (int i = 0; i < 3; i++) {
if (abool[i, 2 - i])
count1++;
}
if (count1 == 3)
return true;
return false;
}
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var a = new long[3, 3];
var abool = new bool[3, 3];
for (int i = 0; i < 3; i++) {
var input = Reads();
for (int j = 0; j < 3; j++) {
a[i, j] = input[j];
abool[i, j] = false;
}
}
var n = Read();
var b = new long[n];
for (int j = 0; j < n; j++) {
b[j] = Read();
}
for (int k = 0; k < n; k++) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (a[i, j] == b[k])
abool[i, j] = true;
}
}
}
if (bingo(abool))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
Console.Out.Flush();
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static bool bingo(bool[,] abool) {
for (int i = 0; i < 3; i++) {
var count = 0;
for (int j = 0; j < 3; j++) {
if (abool[i, j])
count++;
}
if (count == 3)
return true;
}
for (int i = 0; i < 3; i++) {
var count = 0;
for (int j = 0; j < 3; j++) {
if (abool[j, i])
count++;
}
if (count == 3)
return true;
}
var count0 = 0;
for (int i = 0; i < 3; i++) {
if (abool[i, i])
count0++;
}
if (count0 == 3)
return true;
var count1 = 0;
for (int i = 0; i < 3; i++) {
if (abool[i, 2 - i])
count1++;
}
if (count1 == 3)
return true;
return false;
}
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var a = new long[3, 3];
var abool = new bool[3, 3];
for (int i = 0; i < 3; i++) {
var input = Reads();
for (int j = 0; j < 3; j++) {
a[i, j] = input[j];
abool[i, j] = false;
}
}
var n = Read();
var b = new long[n];
for (int j = 0; j < n; j++) {
b[j] = Read();
}
for (int k = 0; k < n; k++) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (a[i, j] == b[k])
abool[i, j] = true;
}
}
}
if (bingo(abool))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
Console.Out.Flush();
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 559
| 2
|
using System;
public class Hello {
public static void Main() {
int[] All = new int[9];
for (int i = 1; i <= 3; i++) {
string[] a = Console.ReadLine().Split(' ');
for (int j = 0; j < 3; j++) {
All[i + j + 1] = int.Parse(a[j]);
}
}
int N = int.Parse(Console.ReadLine());
for (int k = 0; k < N; k++) {
int get = int.Parse(Console.ReadLine());
for (int l = 0; l < 9; l++) {
if (get == All[l]) {
All[l] = 0; //フラグ
}
}
}
for (int m = 0; m < 3; m++) {
int P = 0;
int Q = 0;
for (int n = 0; n < 3; n++) {
P += All[m * 3 + n]; //横
Q += All[m + n * 3]; //縦
}
if (P == 0 || Q == 0) {
System.Console.WriteLine("Yes");
return;
}
}
if (All[0] + All[4] + All[8] == 0 || All[2] + All[4] + All[6] == 0) {
System.Console.WriteLine("Yes");
return;
}
System.Console.WriteLine("No");
}
}
|
using System;
public class Hello {
public static void Main() {
int[] All = new int[9];
for (int i = 0; i < 3; i++) {
string[] a = Console.ReadLine().Split(' ');
for (int j = 0; j < 3; j++) {
All[i * 3 + j] = int.Parse(a[j]);
}
}
int N = int.Parse(Console.ReadLine());
for (int k = 0; k < N; k++) {
int get = int.Parse(Console.ReadLine());
for (int l = 0; l < 9; l++) {
if (get == All[l]) {
// System.Console.WriteLine(l);
All[l] = 0; //フラグ
}
}
}
for (int m = 0; m < 3; m++) {
int P = 0;
int Q = 0;
for (int n = 0; n < 3; n++) {
P += All[m * 3 + n]; //横
Q += All[m + n * 3]; //縦
// System.Console.WriteLine(P);
}
if (P == 0 || Q == 0) {
System.Console.WriteLine("Yes");
return;
}
}
if (All[0] + All[4] + All[8] == 0 || All[2] + All[4] + All[6] == 0) {
System.Console.WriteLine("Yes");
return;
}
System.Console.WriteLine("No");
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 17, 48], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 12, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 328
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace B {
class Program {
static void Main(string[] args) {
var bingoMap = new List<int>();
foreach (var _ in Enumerable.Range(0, 3)) {
bingoMap.AddRange(
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList());
}
var completeTimes = int.Parse(Console.ReadLine());
var indexs = new List<int>();
foreach (var _ in Enumerable.Range(0, completeTimes)) {
var input = int.Parse(Console.ReadLine());
indexs.Add(bingoMap.IndexOf(input));
}
if (CheckBingo(indexs))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
static bool CheckBingo(List<int> indexs) {
if (indexs.Contains(1)) {
if (indexs.Contains(2))
if (indexs.Contains(3))
return true;
if (indexs.Contains(4))
if (indexs.Contains(7))
return true;
if (indexs.Contains(5))
if (indexs.Contains(9))
return true;
}
if (indexs.Contains(2))
if (indexs.Contains(5))
if (indexs.Contains(8))
return true;
if (indexs.Contains(4))
if (indexs.Contains(5))
if (indexs.Contains(6))
return true;
if (indexs.Contains(3)) {
if (indexs.Contains(6))
if (indexs.Contains(9))
return true;
if (indexs.Contains(5))
if (indexs.Contains(7))
return true;
}
if (indexs.Contains(4))
if (indexs.Contains(5))
if (indexs.Contains(6))
return true;
if (indexs.Contains(7))
if (indexs.Contains(8))
if (indexs.Contains(9))
return true;
return false;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace B {
class Program {
static void Main(string[] args) {
var bingoMap = new List<int>();
foreach (var _ in Enumerable.Range(0, 3)) {
bingoMap.AddRange(
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList());
}
var completeTimes = int.Parse(Console.ReadLine());
var indexs = new List<int>();
foreach (var _ in Enumerable.Range(0, completeTimes)) {
var input = int.Parse(Console.ReadLine());
indexs.Add(bingoMap.IndexOf(input) + 1);
}
if (CheckBingo(indexs))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
static bool CheckBingo(List<int> indexs) {
if (indexs.Contains(1)) {
if (indexs.Contains(2))
if (indexs.Contains(3))
return true;
if (indexs.Contains(4))
if (indexs.Contains(7))
return true;
if (indexs.Contains(5))
if (indexs.Contains(9))
return true;
}
if (indexs.Contains(2))
if (indexs.Contains(5))
if (indexs.Contains(8))
return true;
if (indexs.Contains(4))
if (indexs.Contains(5))
if (indexs.Contains(6))
return true;
if (indexs.Contains(3)) {
if (indexs.Contains(6))
if (indexs.Contains(9))
return true;
if (indexs.Contains(5))
if (indexs.Contains(7))
return true;
}
if (indexs.Contains(4))
if (indexs.Contains(5))
if (indexs.Contains(6))
return true;
if (indexs.Contains(7))
if (indexs.Contains(8))
if (indexs.Contains(9))
return true;
return false;
}
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 450
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TOPSIC {
partial class Program {
static void Main(string[] args) {
string[] A1 = Console.ReadLine().Split(' ');
string[] A2 = Console.ReadLine().Split(' ');
string[] A3 = Console.ReadLine().Split(' ');
int[,] A = new int[3, 3];
for (int i = 0; i < 3; i++) {
A[0, i] = int.Parse(A1[i]);
}
for (int i = 0; i < 3; i++) {
A[1, i] = int.Parse(A1[i]);
}
for (int i = 0; i < 3; i++) {
A[2, i] = int.Parse(A1[i]);
}
string NK = Console.ReadLine();
int N = int.Parse(NK);
int[] b = new int[N];
for (int i = 0; i < N; i++) {
b[i] = int.Parse(Console.ReadLine());
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (A[j, k] == b[i]) {
A[j, k] = 0;
}
}
}
}
for (int j = 0; j < 3; j++) {
int ans = 0;
for (int k = 0; k < 3; k++) {
ans += A[j, k];
}
if (ans == 0) {
Console.WriteLine("Yes");
return;
}
}
for (int j = 0; j < 3; j++) {
int ans = 0;
for (int k = 0; k < 3; k++) {
ans += A[k, j];
}
if (ans == 0) {
Console.WriteLine("Yes");
return;
}
}
if (A[0, 0] == 0 && A[1, 1] == 0 && A[2, 2] == 0) {
Console.WriteLine("Yes");
return;
}
if (A[0, 2] == 0 && A[1, 1] == 0 && A[2, 0] == 0) {
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TOPSIC {
partial class Program {
static void Main(string[] args) {
string[] A1 = Console.ReadLine().Split(' ');
string[] A2 = Console.ReadLine().Split(' ');
string[] A3 = Console.ReadLine().Split(' ');
int[,] A = new int[3, 3];
for (int i = 0; i < 3; i++) {
A[0, i] = int.Parse(A1[i]);
}
for (int i = 0; i < 3; i++) {
A[1, i] = int.Parse(A2[i]);
}
for (int i = 0; i < 3; i++) {
A[2, i] = int.Parse(A3[i]);
}
string NK = Console.ReadLine();
int N = int.Parse(NK);
int[] b = new int[N];
for (int i = 0; i < N; i++) {
b[i] = int.Parse(Console.ReadLine());
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (A[j, k] == b[i]) {
A[j, k] = 0;
}
}
}
}
for (int j = 0; j < 3; j++) {
int ans = 0;
for (int k = 0; k < 3; k++) {
ans += A[j, k];
}
if (ans == 0) {
Console.WriteLine("Yes");
return;
}
}
for (int j = 0; j < 3; j++) {
int ans = 0;
for (int k = 0; k < 3; k++) {
ans += A[k, j];
}
if (ans == 0) {
Console.WriteLine("Yes");
return;
}
}
if (A[0, 0] == 0 && A[1, 1] == 0 && A[2, 2] == 0) {
Console.WriteLine("Yes");
return;
}
if (A[0, 2] == 0 && A[1, 1] == 0 && A[2, 0] == 0) {
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
}
}
|
[["-", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22]]
| 8
| 572
| 4
|
using System;
namespace B {
class Program {
static void Main(string[] args) {
Console.WriteLine(solver() ? "Yes" : "No");
}
static bool solver() {
var A = new int[3, 3];
var isHit = new bool[3, 3];
for (int i = 0; i < 3; i++) {
var read = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
for (int j = 0; j < 3; j++) {
A[i, j] = read[j];
isHit[i, j] = false;
}
}
var N = int.Parse(Console.ReadLine());
for (int i = 0; i < N; i++) {
var read = int.Parse(Console.ReadLine());
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (A[j, k] == read)
isHit[j, k] = true;
}
}
}
for (int h = 0; h < 3; h++) {
var result = true;
for (int v = 0; v < 3; v++) {
if (!isHit[h, v]) {
result = false;
break;
}
if (result)
return true;
}
}
for (int v = 0; v < 3; v++) {
var result = true;
for (int h = 0; h < 3; h++) {
if (!isHit[h, v]) {
result = false;
break;
}
}
if (result)
return true;
}
if (isHit[0, 0] && isHit[1, 1] && isHit[2, 2])
return true;
if (isHit[2, 0] && isHit[1, 1] && isHit[0, 2])
return true;
return false;
}
}
}
|
using System;
namespace B {
class Program {
static void Main(string[] args) {
Console.WriteLine(solver() ? "Yes" : "No");
}
static bool solver() {
var A = new int[3, 3];
var isHit = new bool[3, 3];
for (int i = 0; i < 3; i++) {
var read = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
for (int j = 0; j < 3; j++) {
A[i, j] = read[j];
isHit[i, j] = false;
}
}
var N = int.Parse(Console.ReadLine());
for (int i = 0; i < N; i++) {
var read = int.Parse(Console.ReadLine());
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (A[j, k] == read)
isHit[j, k] = true;
}
}
}
for (int h = 0; h < 3; h++) {
var result = true;
for (int v = 0; v < 3; v++) {
if (!isHit[h, v]) {
result = false;
break;
}
}
if (result)
return true;
}
for (int v = 0; v < 3; v++) {
var result = true;
for (int h = 0; h < 3; h++) {
if (!isHit[h, v]) {
result = false;
break;
}
}
if (result)
return true;
}
if (isHit[0, 0] && isHit[1, 1] && isHit[2, 2])
return true;
if (isHit[2, 0] && isHit[1, 1] && isHit[0, 2])
return true;
return false;
}
}
}
|
[["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 421
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
//文字列を読み込む
int[] A1 =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int[] A2 =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int[] A3 =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int N = int.Parse(Console.ReadLine());
for (int i = 0; i < N; i++) {
int bi = int.Parse(Console.ReadLine());
for (int j = 0; j < 3; j++) {
if (A1[j] == bi) {
A1[j] = 0;
}
if (A2[j] == bi) {
A3[j] = 0;
}
if (A3[j] == bi) {
A3[j] = 0;
}
}
}
int sumLine1 = A1.Sum();
int sumLine2 = A2.Sum();
int sumLine3 = A3.Sum();
int sumColumn1 = A1[0] + A2[0] + A3[0];
int sumColumn2 = A1[1] + A2[1] + A3[1];
int sumColumn3 = A1[2] + A2[2] + A3[2];
int sumR = A1[0] + A2[1] + A3[2];
int sumL = A1[2] + A2[1] + A3[0];
if (sumLine1 == 0 || sumLine2 == 0 || sumLine3 == 0 || sumColumn1 == 0 ||
sumColumn2 == 0 || sumColumn3 == 0 || sumR == 0 || sumL == 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
//文字列を読み込む
int[] A1 =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int[] A2 =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int[] A3 =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int N = int.Parse(Console.ReadLine());
for (int i = 0; i < N; i++) {
int bi = int.Parse(Console.ReadLine());
for (int j = 0; j < 3; j++) {
if (A1[j] == bi) {
A1[j] = 0;
}
if (A2[j] == bi) {
A2[j] = 0;
}
if (A3[j] == bi) {
A3[j] = 0;
}
}
}
int sumLine1 = A1.Sum();
int sumLine2 = A2.Sum();
int sumLine3 = A3.Sum();
int sumColumn1 = A1[0] + A2[0] + A3[0];
int sumColumn2 = A1[1] + A2[1] + A3[1];
int sumColumn3 = A1[2] + A2[2] + A3[2];
int sumR = A1[0] + A2[1] + A3[2];
int sumL = A1[2] + A2[1] + A3[0];
if (sumLine1 == 0 || sumLine2 == 0 || sumLine3 == 0 || sumColumn1 == 0 ||
sumColumn2 == 0 || sumColumn3 == 0 || sumR == 0 || sumL == 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["-", 64, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 64, 196, 0, 1, 0, 11, 31, 204, 205, 22]]
| 8
| 421
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp18 {
class Program {
static void Main(string[] args) {
long[] iti =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long[] ni =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long[] san =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long nsuu = int.Parse(Console.ReadLine());
long teki = 0;
for (long i = 0; i < nsuu; i++) {
teki = int.Parse(Console.ReadLine());
for (long n = 0; n < 3; n++) {
if (iti[n] == teki) {
iti[n] = -1;
} else if (ni[n] == teki) {
ni[n] = -1;
} else if (san[n] == teki) {
san[n] = -1;
}
}
}
//結果出る誤リオス
bool hantei = false;
if (iti[0] == -1 && iti[1] == -1 && iti[2] == -1) {
hantei = true;
} else if (ni[0] == -1 && ni[1] == -1 && ni[2] == -1) {
hantei = true;
} else if (san[0] == -1 && san[1] == -1 && san[2] == -1) {
hantei = true;
} else if (iti[0] == -1 && ni[1] == -1 && san[2] == -1) {
hantei = true;
} else if (iti[2] == -1 && ni[1] == -1 && san[0] == -1) {
hantei = true;
}
for (long n = 0; n >= 3; n++) {
if (iti[n] == -1 && ni[n] == -1 && san[n] == -1) {
hantei = true;
}
}
if (hantei) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp18 {
class Program {
static void Main(string[] args) {
long[] iti =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long[] ni =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long[] san =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long nsuu = int.Parse(Console.ReadLine());
long teki = 0;
for (long i = 0; i < nsuu; i++) {
teki = int.Parse(Console.ReadLine());
for (long n = 0; n < 3; n++) {
if (iti[n] == teki) {
iti[n] = -1;
} else if (ni[n] == teki) {
ni[n] = -1;
} else if (san[n] == teki) {
san[n] = -1;
}
}
}
//結果出る誤リオス
bool hantei = false;
if (iti[0] == -1 && iti[1] == -1 && iti[2] == -1) {
hantei = true;
} else if (ni[0] == -1 && ni[1] == -1 && ni[2] == -1) {
hantei = true;
} else if (san[0] == -1 && san[1] == -1 && san[2] == -1) {
hantei = true;
} else if (iti[0] == -1 && ni[1] == -1 && san[2] == -1) {
hantei = true;
} else if (iti[2] == -1 && ni[1] == -1 && san[0] == -1) {
hantei = true;
}
for (long n = 0; n < 3; n++) {
if (iti[n] == -1 && ni[n] == -1 && san[n] == -1) {
hantei = true;
}
}
if (hantei) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18]]
| 8
| 516
| 2
|
using System;
using static System.Console;
using System.Linq;
namespace AC {
public class shiokara {
static void Main(string[] args) {
int[] aa = new int[9];
int[] a1 = new int[3];
int[] a2 = new int[3];
aa = ReadLine().Split(' ').Select(int.Parse).ToArray();
a1 = ReadLine().Split(' ').Select(int.Parse).ToArray();
a2 = ReadLine().Split(' ').Select(int.Parse).ToArray();
int[] aaa = aa.Concat(a1).ToArray();
int[] a = aaa.Concat(a2).ToArray();
int n = int.Parse(ReadLine());
for (int i = 0; i < n; i++) {
var b = int.Parse(ReadLine());
for (int j = 0; j < 9; j++) {
if (a[j] == b) {
a[j] = 0;
}
}
}
if (a[0] == 0) {
if (a[1] + a[2] == 0) {
WriteLine("Yes");
return;
}
if (a[4] + a[8] == 0) {
WriteLine("Yes");
return;
}
if (a[3] + a[6] == 0) {
WriteLine("Yes");
return;
}
}
if (a[1] == 0) {
if (a[3] + a[6] == 0) {
WriteLine("Yes");
return;
}
}
if (a[2] == 0) {
if (a[4] + a[6] == 0) {
WriteLine("Yes");
return;
}
if (a[5] + a[8] == 0) {
WriteLine("Yes");
return;
}
}
if (a[3] == 0) {
if (a[4] + a[5] == 0) {
WriteLine("Yes");
return;
}
}
if (a[6] == 0) {
if (a[7] + a[8] == 0) {
WriteLine("Yes");
return;
}
}
WriteLine("No");
}
}
}
|
using System;
using static System.Console;
using System.Linq;
namespace AC {
public class shiokara {
static void Main(string[] args) {
int[] aa = new int[9];
int[] a1 = new int[3];
int[] a2 = new int[3];
aa = ReadLine().Split(' ').Select(int.Parse).ToArray();
a1 = ReadLine().Split(' ').Select(int.Parse).ToArray();
a2 = ReadLine().Split(' ').Select(int.Parse).ToArray();
int[] aaa = aa.Concat(a1).ToArray();
int[] a = aaa.Concat(a2).ToArray();
int n = int.Parse(ReadLine());
for (int i = 0; i < n; i++) {
var b = int.Parse(ReadLine());
for (int j = 0; j < 9; j++) {
if (a[j] == b) {
a[j] = 0;
}
}
}
if (a[0] == 0) {
if (a[1] + a[2] == 0) {
WriteLine("Yes");
return;
}
if (a[4] + a[8] == 0) {
WriteLine("Yes");
return;
}
if (a[3] + a[6] == 0) {
WriteLine("Yes");
return;
}
}
if (a[1] == 0) {
if (a[4] + a[7] == 0) {
WriteLine("Yes");
return;
}
}
if (a[2] == 0) {
if (a[4] + a[6] == 0) {
WriteLine("Yes");
return;
}
if (a[5] + a[8] == 0) {
WriteLine("Yes");
return;
}
}
if (a[3] == 0) {
if (a[4] + a[5] == 0) {
WriteLine("Yes");
return;
}
}
if (a[6] == 0) {
if (a[7] + a[8] == 0) {
WriteLine("Yes");
return;
}
}
WriteLine("No");
}
}
}
|
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 507
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC157B {
class Program {
static void Main(string[] args) {
var As = new int [3][];
for (var i = 0; i < 3; i++)
As[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
var N = int.Parse(Console.ReadLine());
var bs = new HashSet<int>();
for (var i = 0; i < N; i++)
bs.Add(int.Parse(Console.ReadLine()));
for (var i = 0; i < 3; i++) {
var bingo = false;
for (var j = 0; j < 3; j++)
bingo &= bs.Contains(As[i][j]);
if (bingo) {
Console.WriteLine("Yes");
return;
}
}
for (var i = 0; i < 3; i++) {
var bingo = false;
for (var j = 0; j < 3; j++)
bingo &= bs.Contains(As[j][i]);
if (bingo) {
Console.WriteLine("Yes");
return;
}
}
if (bs.Contains(As[0][0]) && bs.Contains(As[1][1]) &&
bs.Contains(As[2][2])) {
Console.WriteLine("Yes");
return;
}
if (bs.Contains(As[0][2]) && bs.Contains(As[1][1]) &&
bs.Contains(As[2][0])) {
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC157B {
class Program {
static void Main(string[] args) {
var As = new int [3][];
for (var i = 0; i < 3; i++)
As[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
var N = int.Parse(Console.ReadLine());
var bs = new HashSet<int>();
for (var i = 0; i < N; i++)
bs.Add(int.Parse(Console.ReadLine()));
for (var i = 0; i < 3; i++) {
var bingo = true;
for (var j = 0; j < 3; j++)
bingo &= bs.Contains(As[i][j]);
if (bingo) {
Console.WriteLine("Yes");
return;
}
}
for (var i = 0; i < 3; i++) {
var bingo = true;
for (var j = 0; j < 3; j++)
bingo &= bs.Contains(As[j][i]);
if (bingo) {
Console.WriteLine("Yes");
return;
}
}
if (bs.Contains(As[0][0]) && bs.Contains(As[1][1]) &&
bs.Contains(As[2][2])) {
Console.WriteLine("Yes");
return;
}
if (bs.Contains(As[0][2]) && bs.Contains(As[1][1]) &&
bs.Contains(As[2][0])) {
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146]]
| 8
| 391
| 4
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace MyProject {
class Program {
static void Main(string[] args) {
#if Local
var sw = new Stopwatch();
sw.Start();
Console.SetIn(new StreamReader("input.in"));
#endif
var solver = new Solver();
solver.Solve();
#if Local
Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
}
}
class Solver {
public void Solve() {
var A = new List<List<int>>();
foreach (var i in Enumerable.Range(0, 3)) {
A.Add(
Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToList());
}
// 穴をあける
var N = int.Parse(Console.ReadLine());
foreach (var i in Enumerable.Range(0, N)) {
var b = int.Parse(Console.ReadLine());
var coordinate = Coordinate.GetHitCoordinate(A, b);
if (coordinate != null) {
A[coordinate.I][coordinate.J] = 0;
}
}
// ビンゴチェック
var answer = "No";
do {
// 横
foreach (var i in Enumerable.Range(0, 3)) {
if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) {
answer = "Yes";
break;
}
}
if (answer == "Yes") {
break;
}
// 縦
foreach (var j in Enumerable.Range(0, 3)) {
if (A[0][j] == 0 && A[1][j] == 0 && A[2][j] == 0) {
answer = "Yes";
break;
}
}
if (answer == "Yes") {
break;
}
// 斜め
{
if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) {
answer = "Yes";
break;
}
if (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) {
break;
}
}
} while (false);
Console.WriteLine(answer);
}
}
class Coordinate {
public int I { get; set; }
public int J { get; set; }
public static Coordinate GetHitCoordinate(List<List<int>> A, int item) {
foreach (var i in Enumerable.Range(0, A.Count)) {
foreach (var j in Enumerable.Range(0, A[i].Count)) {
if (item == A[i][j]) {
return new Coordinate { I = i, J = j };
}
}
}
return null;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace MyProject {
class Program {
static void Main(string[] args) {
#if Local
var sw = new Stopwatch();
sw.Start();
Console.SetIn(new StreamReader("input.in"));
#endif
var solver = new Solver();
solver.Solve();
#if Local
Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
}
}
class Solver {
public void Solve() {
var A = new List<List<int>>();
foreach (var i in Enumerable.Range(0, 3)) {
A.Add(
Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToList());
}
// 穴をあける
var N = int.Parse(Console.ReadLine());
foreach (var i in Enumerable.Range(0, N)) {
var b = int.Parse(Console.ReadLine());
var coordinate = Coordinate.GetHitCoordinate(A, b);
if (coordinate != null) {
A[coordinate.I][coordinate.J] = 0;
}
}
// ビンゴチェック
var answer = "No";
do {
// 横
foreach (var i in Enumerable.Range(0, 3)) {
if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) {
answer = "Yes";
break;
}
}
if (answer == "Yes") {
break;
}
// 縦
foreach (var j in Enumerable.Range(0, 3)) {
if (A[0][j] == 0 && A[1][j] == 0 && A[2][j] == 0) {
answer = "Yes";
break;
}
}
if (answer == "Yes") {
break;
}
// 斜め
{
if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) {
answer = "Yes";
break;
}
if (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) {
answer = "Yes";
break;
}
}
} while (false);
Console.WriteLine(answer);
}
}
class Coordinate {
public int I { get; set; }
public int J { get; set; }
public static Coordinate GetHitCoordinate(List<List<int>> A, int item) {
foreach (var i in Enumerable.Range(0, A.Count)) {
foreach (var j in Enumerable.Range(0, A[i].Count)) {
if (item == A[i][j]) {
return new Coordinate { I = i, J = j };
}
}
}
return null;
}
}
}
|
[["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 62], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 0, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 616
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var row1 =
Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();
var row2 =
Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();
var row3 =
Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();
var board = new Board(row1, row2, row3);
var n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++) {
var num = int.Parse(Console.ReadLine());
board.SetNum(num);
}
Console.WriteLine(board.GetResult() ? "Yes" : "No");
}
}
class Board {
IReadOnlyList<Cell> cells;
public Board(int[] row1, int[] row2, int[] row3) {
var list = new List<Cell>();
list.AddRange(row1.Select((r, i) => new Cell(0, i, r)));
list.AddRange(row2.Select((r, i) => new Cell(1, i, r)));
list.AddRange(row3.Select((r, i) => new Cell(2, i, r)));
this.cells = list;
}
internal bool GetResult() {
//縦
for (int i = 0; i < 2; i++) {
if (cells.Where(c => c.ClmIdx == i).All(c => c.IsSet))
return true;
}
//横
for (int i = 0; i < 2; i++) {
if (cells.Where(c => c.RowIdx == i).All(c => c.IsSet))
return true;
}
//斜め
if (new[] { cells[0], cells[4], cells[8] }.All(c => c.IsSet))
return true;
if (new[] { cells[2], cells[4], cells[6] }.All(c => c.IsSet))
return true;
return false;
}
internal void SetNum(int num) {
var target = cells.FirstOrDefault(c => c.Num == num);
if (target != null) {
target.IsSet = true;
}
}
}
class Cell {
public bool IsSet { get; set; }
public int Num { get; }
public int RowIdx { get; }
public int ClmIdx { get; }
public Cell(int row, int clm, int num) {
this.RowIdx = row;
this.ClmIdx = clm;
this.Num = num;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var row1 =
Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();
var row2 =
Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();
var row3 =
Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();
var board = new Board(row1, row2, row3);
var n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++) {
var num = int.Parse(Console.ReadLine());
board.SetNum(num);
}
Console.WriteLine(board.GetResult() ? "Yes" : "No");
}
}
class Board {
IReadOnlyList<Cell> cells;
public Board(int[] row1, int[] row2, int[] row3) {
var list = new List<Cell>();
list.AddRange(row1.Select((r, i) => new Cell(0, i, r)));
list.AddRange(row2.Select((r, i) => new Cell(1, i, r)));
list.AddRange(row3.Select((r, i) => new Cell(2, i, r)));
this.cells = list;
}
internal bool GetResult() {
//縦
for (int i = 0; i <= 2; i++) {
if (cells.Where(c => c.ClmIdx == i).All(c => c.IsSet))
return true;
}
//横
for (int i = 0; i <= 2; i++) {
if (cells.Where(c => c.RowIdx == i).All(c => c.IsSet))
return true;
}
//斜め
if (new[] { cells[0], cells[4], cells[8] }.All(c => c.IsSet))
return true;
if (new[] { cells[2], cells[4], cells[6] }.All(c => c.IsSet))
return true;
return false;
}
internal void SetNum(int num) {
var target = cells.FirstOrDefault(c => c.Num == num);
if (target != null) {
target.IsSet = true;
}
}
}
class Cell {
public bool IsSet { get; set; }
public int Num { get; }
public int RowIdx { get; }
public int ClmIdx { get; }
public Cell(int row, int clm, int num) {
this.RowIdx = row;
this.ClmIdx = clm;
this.Num = num;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 622
| 4
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
/*
double a;
a = double.Parse(Console.ReadLine()); //標準入力
//string[] str =
Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
//b = int.Parse(str[0]);
//数値で受け取りたい場合は変換する
//c = int.Parse(str[1]);
//Console.Write("改行なし a = {0} b = {1}
c = {2}", a, b, c)//改行なし出力
//Console.WriteLine("改行あり a = {0} b =
{1} c = {2}", a, b, c);//改行付き出力 Console.WriteLine(Math.Ceiling(a/2));
Console.ReadLine();
*/
string input = Console.ReadLine();
string[,] s = new string[3, 3];
bool[,] b = new bool[3, 3];
string[] sa = input.Split(' ');
s[0, 0] = sa[0];
s[0, 1] = sa[1];
s[0, 2] = sa[2];
input = Console.ReadLine();
sa = input.Split(' ');
s[1, 0] = sa[0];
s[1, 1] = sa[1];
s[1, 2] = sa[2];
input = Console.ReadLine();
sa = input.Split(' ');
s[2, 0] = sa[0];
s[2, 1] = sa[1];
s[2, 2] = sa[2];
b[0, 0] = false;
b[0, 1] = false;
b[0, 2] = false;
b[1, 0] = false;
b[1, 1] = false;
b[1, 2] = false;
b[2, 0] = false;
b[2, 1] = false;
b[2, 2] = false;
int iinput = int.Parse(Console.ReadLine());
string[] n = new string[iinput];
for (int i = 0; i < iinput; i++) {
n[i] = Console.ReadLine();
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < iinput; k++) {
if (!b[i, j]) {
if (s[i, j] == n[k]) {
b[i, j] = true;
} else {
b[i, j] = false;
}
}
}
}
}
int r = 0;
if (b[0, 0] && b[0, 1] && b[0, 2]) {
r++;
}
if (b[1, 0] && b[1, 1] && b[1, 2]) {
r++;
}
if (b[2, 0] && b[2, 1] && b[2, 2]) {
r++;
}
if (b[0, 0] && b[1, 0] && b[2, 0]) {
r++;
}
if (b[0, 1] && b[1, 1] && b[2, 1]) {
r++;
}
if (b[0, 2] && b[1, 2] && b[2, 2]) {
r++;
}
if (b[0, 0] && b[1, 1] && b[2, 2]) {
r++;
}
if (b[1, 2] && b[1, 1] && b[2, 0]) {
r++;
}
if (r > 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
/*
double a;
a = double.Parse(Console.ReadLine()); //標準入力
//string[] str =
Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
//b = int.Parse(str[0]);
//数値で受け取りたい場合は変換する
//c = int.Parse(str[1]);
//Console.Write("改行なし a = {0} b = {1}
c = {2}", a, b, c)//改行なし出力
//Console.WriteLine("改行あり a = {0} b =
{1} c = {2}", a, b, c);//改行付き出力 Console.WriteLine(Math.Ceiling(a/2));
Console.ReadLine();
*/
string input = Console.ReadLine();
string[,] s = new string[3, 3];
bool[,] b = new bool[3, 3];
string[] sa = input.Split(' ');
s[0, 0] = sa[0];
s[0, 1] = sa[1];
s[0, 2] = sa[2];
input = Console.ReadLine();
sa = input.Split(' ');
s[1, 0] = sa[0];
s[1, 1] = sa[1];
s[1, 2] = sa[2];
input = Console.ReadLine();
sa = input.Split(' ');
s[2, 0] = sa[0];
s[2, 1] = sa[1];
s[2, 2] = sa[2];
b[0, 0] = false;
b[0, 1] = false;
b[0, 2] = false;
b[1, 0] = false;
b[1, 1] = false;
b[1, 2] = false;
b[2, 0] = false;
b[2, 1] = false;
b[2, 2] = false;
int iinput = int.Parse(Console.ReadLine());
string[] n = new string[iinput];
for (int i = 0; i < iinput; i++) {
n[i] = Console.ReadLine();
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < iinput; k++) {
if (!b[i, j]) {
if (s[i, j] == n[k]) {
b[i, j] = true;
} else {
b[i, j] = false;
}
}
}
}
}
int r = 0;
if (b[0, 0] && b[0, 1] && b[0, 2]) {
r++;
}
if (b[1, 0] && b[1, 1] && b[1, 2]) {
r++;
}
if (b[2, 0] && b[2, 1] && b[2, 2]) {
r++;
}
if (b[0, 0] && b[1, 0] && b[2, 0]) {
r++;
}
if (b[0, 1] && b[1, 1] && b[2, 1]) {
r++;
}
if (b[0, 2] && b[1, 2] && b[2, 2]) {
r++;
}
if (b[0, 0] && b[1, 1] && b[2, 2]) {
r++;
}
if (b[0, 2] && b[1, 1] && b[2, 0]) {
r++;
}
if (r > 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 708
| 2
|
using System;
namespace ConsoleApp6 {
class Program {
static void Main(string[] args) {
int[,] card = new int[3, 3];
for (int i = 0; i <= 2; i++) {
string[] number = Console.ReadLine().Split(' ');
for (int j = 0; j <= 2; j++) {
card[i, j] = int.Parse(number[j]);
}
}
int N = int.Parse(Console.ReadLine());
// string[] str = Console.ReadLine().Split(' ');
// string s = Console.ReadLine();
// string[] str1 = Console.ReadLine().Split(' ');
// int[] number = str.Select(int.Parse).ToArray();
for (int i = 0; i <= N - 1; i++) {
int b = int.Parse(Console.ReadLine());
for (int j = 0; j <= 2; j++) {
for (int k = 0; k <= 2; k++) {
if (card[j, k] == b) {
card[j, k] = 0;
}
}
}
}
int[] sum = new int[8];
for (int i = 0; i <= 2; i++) {
sum[i] = card[i, 0] + card[i, 1] + card[i, 2];
sum[i + 3] = card[0, i] + card[1, i] + card[2, i];
}
sum[6] = card[0, 0] + card[1, 1] + card[2, 2];
sum[7] = card[0, 2] + card[1, 1] + card[2, 0];
bool check = false;
for (int i = 0; i <= 7; i++) {
if (sum[i] == 0) {
check = true;
}
}
if (check)
Console.WriteLine("YES");
else
Console.WriteLine("NO");
}
}
}
|
using System;
namespace ConsoleApp6 {
class Program {
static void Main(string[] args) {
int[,] card = new int[3, 3];
for (int i = 0; i <= 2; i++) {
string[] number = Console.ReadLine().Split(' ');
for (int j = 0; j <= 2; j++) {
card[i, j] = int.Parse(number[j]);
}
}
int N = int.Parse(Console.ReadLine());
for (int i = 0; i <= N - 1; i++) {
int b = int.Parse(Console.ReadLine());
for (int j = 0; j <= 2; j++) {
for (int k = 0; k <= 2; k++) {
if (card[j, k] == b) {
card[j, k] = 0;
}
}
}
}
int[] sum = new int[8];
for (int i = 0; i <= 2; i++) {
sum[i] = card[i, 0] + card[i, 1] + card[i, 2];
sum[i + 3] = card[0, i] + card[1, i] + card[2, i];
}
sum[6] = card[0, 0] + card[1, 1] + card[2, 2];
sum[7] = card[0, 2] + card[1, 1] + card[2, 0];
bool check = false;
for (int i = 0; i <= 7; i++) {
if (sum[i] == 0) {
check = true;
}
}
if (check)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 399
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
using E = System.Linq.Enumerable;
public class Program {
public static void Main() {
var card = new int [3][];
for (int i = 0; i < card.Length; ++i) {
card[i] = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
var n = int.Parse(Console.ReadLine());
var seqB = Console.In.ReadToEnd()
.Split(Environment.NewLine.ToCharArray(),
StringSplitOptions.RemoveEmptyEntries)
.Select(x => int.Parse(x))
.ToArray();
var indices = new Dictionary<int, int>();
for (int i = 0; i < card.Length; ++i) {
for (int j = 0; j < card[i].Length; ++j) {
indices[card[i][j]] = i << 3 | 1 << j;
}
}
var hit = new int[3];
for (int i = 0; i < seqB.Length; ++i) {
int index;
if (indices.TryGetValue(seqB[i], out index)) {
hit[index >> 3] |= index & 7;
}
}
var bingo = hit.Any(x => x == 7);
bingo = bingo || hit.Aggregate(7, (x, y) => x & y) > 0;
bingo = bingo || (hit[0] & 4 | hit[1] & 2 | hit[0] & 1) == 7 ||
(hit[0] & 1 | hit[1] & 2 | hit[2] & 4) == 7;
Console.WriteLine(bingo ? "Yes" : "No");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using E = System.Linq.Enumerable;
public class Program {
public static void Main() {
var card = new int [3][];
for (int i = 0; i < card.Length; ++i) {
card[i] = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
var n = int.Parse(Console.ReadLine());
var seqB = Console.In.ReadToEnd()
.Split(Environment.NewLine.ToCharArray(),
StringSplitOptions.RemoveEmptyEntries)
.Select(x => int.Parse(x))
.ToArray();
var indices = new Dictionary<int, int>();
for (int i = 0; i < card.Length; ++i) {
for (int j = 0; j < card[i].Length; ++j) {
indices[card[i][j]] = i << 3 | 1 << j;
}
}
var hit = new int[3];
for (int i = 0; i < seqB.Length; ++i) {
int index;
if (indices.TryGetValue(seqB[i], out index)) {
hit[index >> 3] |= index & 7;
}
}
var bingo = hit.Any(x => x == 7);
bingo = bingo || hit.Aggregate(7, (x, y) => x & y) > 0;
bingo = bingo || (hit[0] & 4 | hit[1] & 2 | hit[2] & 1) == 7 ||
(hit[0] & 1 | hit[1] & 2 | hit[2] & 4) == 7;
Console.WriteLine(bingo ? "Yes" : "No");
}
}
|
[["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 388
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello {
private const int MOD_N = 1000000000 + 7;
public static void Main() {
var a = new int [3][];
for (int i = 0; i < a.Length; ++i) {
var t = Console.ReadLine().Split(' ');
var a_ = new int[t.Length];
for (int j = 0; j < a_.Length; ++j)
a_[j] = int.Parse(t[j]);
a[i] = a_;
}
var n = int.Parse(Console.ReadLine());
var b = new int[n];
for (int i = 0; i < b.Length; ++i)
b[i] = int.Parse(Console.ReadLine());
var c = new bool [3][];
for (int i = 0; i < c.Length; ++i)
c[i] = new bool[3];
foreach (var b_ in b) {
for (int i = 0; i < a.Length; ++i) {
var a_ = a[i];
for (int j = 0; j < a_.Length; ++j) {
if (a_[j] == b_) {
c[i][j] = true;
i = a.Length;
break;
}
}
}
}
foreach (var c_ in c) {
var result = true;
foreach (var c__ in c_) {
if (!c__) {
result = false;
break;
}
}
if (result) {
Console.WriteLine("Yes");
return;
}
}
for (int i = 0; i < 3; ++i) {
var result = true;
for (int j = 0; j < 3; ++j) {
if (!c[j][i]) {
result = false;
break;
}
}
if (result) {
Console.WriteLine("Yes");
return;
}
}
var result3 = true;
for (int i = 0; i < 3; ++i) {
if (!c[i][i]) {
result3 = false;
break;
}
}
if (result3) {
Console.WriteLine("Yes");
return;
}
var result2 = true;
for (int i = 0; i < 3; ++i) {
if (!c[2 - i][2 - i]) {
result2 = false;
break;
}
}
if (result2) {
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
private static int GCD(int a, int b) => a > b? GCD_impl(a, b)
: GCD_impl(b, a);
private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
private static long LCM(int a, int b) => (long)a * b / GCD(a, b);
private static int Comb(int m, int n) {
var t = m - n;
if (n > t)
n = t;
long numerator = 1;
for (int i = 0; i < n; ++i) {
numerator *= m - i;
numerator %= MOD_N;
}
long denominator = 1;
for (; n != 0; --n) {
denominator *= n;
denominator %= MOD_N;
}
var inv_denominator = ModInv((int)denominator, MOD_N);
var ret = (int)(numerator * inv_denominator % MOD_N);
return ret >= 0 ? ret : ret + MOD_N;
}
private static int ModInv(int a, int m) {
int b = m, x = 1, y = 0;
while (b != 0) {
var t = a / b;
a -= t * b;
Swap(ref a, ref b);
x -= t * y;
Swap(ref x, ref y);
}
x %= m;
return x >= 0 ? x : x + m;
}
private static void Swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello {
private const int MOD_N = 1000000000 + 7;
public static void Main() {
var a = new int [3][];
for (int i = 0; i < a.Length; ++i) {
var t = Console.ReadLine().Split(' ');
var a_ = new int[t.Length];
for (int j = 0; j < a_.Length; ++j)
a_[j] = int.Parse(t[j]);
a[i] = a_;
}
var n = int.Parse(Console.ReadLine());
var b = new int[n];
for (int i = 0; i < b.Length; ++i)
b[i] = int.Parse(Console.ReadLine());
var c = new bool [3][];
for (int i = 0; i < c.Length; ++i)
c[i] = new bool[3];
foreach (var b_ in b) {
for (int i = 0; i < a.Length; ++i) {
var a_ = a[i];
for (int j = 0; j < a_.Length; ++j) {
if (a_[j] == b_) {
c[i][j] = true;
i = a.Length;
break;
}
}
}
}
foreach (var c_ in c) {
var result = true;
foreach (var c__ in c_) {
if (!c__) {
result = false;
break;
}
}
if (result) {
Console.WriteLine("Yes");
return;
}
}
for (int i = 0; i < 3; ++i) {
var result = true;
for (int j = 0; j < 3; ++j) {
if (!c[j][i]) {
result = false;
break;
}
}
if (result) {
Console.WriteLine("Yes");
return;
}
}
var result3 = true;
for (int i = 0; i < 3; ++i) {
if (!c[i][i]) {
result3 = false;
break;
}
}
if (result3) {
Console.WriteLine("Yes");
return;
}
var result2 = true;
for (int i = 0; i < 3; ++i) {
if (!c[i][2 - i]) {
result2 = false;
break;
}
}
if (result2) {
Console.WriteLine("Yes");
return;
}
Console.WriteLine("No");
}
private static int GCD(int a, int b) => a > b? GCD_impl(a, b)
: GCD_impl(b, a);
private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
private static long LCM(int a, int b) => (long)a * b / GCD(a, b);
private static int Comb(int m, int n) {
var t = m - n;
if (n > t)
n = t;
long numerator = 1;
for (int i = 0; i < n; ++i) {
numerator *= m - i;
numerator %= MOD_N;
}
long denominator = 1;
for (; n != 0; --n) {
denominator *= n;
denominator %= MOD_N;
}
var inv_denominator = ModInv((int)denominator, MOD_N);
var ret = (int)(numerator * inv_denominator % MOD_N);
return ret >= 0 ? ret : ret + MOD_N;
}
private static int ModInv(int a, int m) {
int b = m, x = 1, y = 0;
while (b != 0) {
var t = a / b;
a -= t * b;
Swap(ref a, ref b);
x -= t * y;
Swap(ref x, ref y);
}
x %= m;
return x >= 0 ? x : x + m;
}
private static void Swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
}
|
[["-", 205, 204, 206, 207, 0, 28, 0, 16, 31, 203], ["-", 205, 204, 206, 207, 0, 28, 0, 16, 17, 33]]
| 8
| 883
| 2
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Diagnostics.Contracts;
class Program {
static void Main() {
var bingo = new List<int>();
bingo.AddRange(MyUtil.ReadintArray());
bingo.AddRange(MyUtil.ReadintArray());
bingo.AddRange(MyUtil.ReadintArray());
var result = new bool[9];
var count = int.Parse(ReadLine());
var input = new int[count];
for (int i = 0; i < count; i++) {
input[i] = int.Parse(ReadLine());
if (bingo.Contains(input[i])) {
var index = bingo.IndexOf(input[i]);
result[index] = true;
}
}
bool flag = true;
bool b = false;
for (int x = 0; x < 9; x += 3) {
flag = true;
for (int j = 0; j < 2; j++) {
flag = flag && result[x + j];
}
if (flag) {
b = true;
}
}
for (int x = 0; x < 2; x++) {
flag = true;
for (int j = 0; j < 9; j += 3) {
flag = flag && result[x + j];
}
if (flag) {
b = true;
}
}
if (result[0] && result[4] && result[8]) {
b = true;
}
if (result[2] && result[4] && result[6]) {
b = true;
}
WriteLine(b ? "Yes" : "No");
ReadKey();
}
}
static class MyUtil {
/// <summary>
/// 指定の桁のビットを取得します。
/// </summary>
/// <param name="num"></param>
/// <param name="count">取得する桁。</param>
/// <returns></returns>
public static int GetBit(this int num, int count) {
int mask = (int)Math.Pow(2, count - 1);
return (num & mask) == 0 ? 0 : 1;
}
/// <summary>
/// <c>int</c>を2進数ビット配列に変換します。
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public static int[] ToBitArray(this int num) {
const int size = sizeof(int) * 8;
var array = new int[size];
for (int i = 0; i < size; i++) {
array[i] = num.GetBit(size - i);
}
return array;
}
public static long[] ReadlongArray() {
return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
}
public static int[] ReadintArray() {
return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
}
/// <summary>
/// <see
/// cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="ts"></param>
public static void WriteToConsole<T>(this IEnumerable<T> ts) {
StringBuilder stringBuilder = new StringBuilder();
foreach (T t in ts) {
stringBuilder.Append(t.ToString());
stringBuilder.Append(" ");
}
stringBuilder.Remove(stringBuilder.Length - 1, 1);
Console.WriteLine(stringBuilder.ToString());
}
public static void WriteToDebugConsole<T>(this IEnumerable<T> ts) {
StringBuilder stringBuilder = new StringBuilder();
foreach (T t in ts) {
stringBuilder.Append(t.ToString());
stringBuilder.Append(" ");
}
stringBuilder.Remove(stringBuilder.Length - 1, 1);
System.Diagnostics.Debug.WriteLine(stringBuilder.ToString());
}
}
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Diagnostics.Contracts;
class Program {
static void Main() {
var bingo = new List<int>();
bingo.AddRange(MyUtil.ReadintArray());
bingo.AddRange(MyUtil.ReadintArray());
bingo.AddRange(MyUtil.ReadintArray());
var result = new bool[9];
var count = int.Parse(ReadLine());
var input = new int[count];
for (int i = 0; i < count; i++) {
input[i] = int.Parse(ReadLine());
if (bingo.Contains(input[i])) {
var index = bingo.IndexOf(input[i]);
result[index] = true;
}
}
bool flag = true;
bool b = false;
for (int x = 0; x < 9; x += 3) {
flag = true;
for (int j = 0; j < 3; j++) {
flag = flag && result[x + j];
}
if (flag) {
b = true;
}
}
for (int x = 0; x < 3; x++) {
flag = true;
for (int j = 0; j < 9; j += 3) {
flag = flag && result[x + j];
}
if (flag) {
b = true;
}
}
if (result[0] && result[4] && result[8]) {
b = true;
}
if (result[2] && result[4] && result[6]) {
b = true;
}
WriteLine(b ? "Yes" : "No");
ReadKey();
}
}
static class MyUtil {
/// <summary>
/// 指定の桁のビットを取得します。
/// </summary>
/// <param name="num"></param>
/// <param name="count">取得する桁。</param>
/// <returns></returns>
public static int GetBit(this int num, int count) {
int mask = (int)Math.Pow(2, count - 1);
return (num & mask) == 0 ? 0 : 1;
}
/// <summary>
/// <c>int</c>を2進数ビット配列に変換します。
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public static int[] ToBitArray(this int num) {
const int size = sizeof(int) * 8;
var array = new int[size];
for (int i = 0; i < size; i++) {
array[i] = num.GetBit(size - i);
}
return array;
}
public static long[] ReadlongArray() {
return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
}
public static int[] ReadintArray() {
return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
}
/// <summary>
/// <see
/// cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="ts"></param>
public static void WriteToConsole<T>(this IEnumerable<T> ts) {
StringBuilder stringBuilder = new StringBuilder();
foreach (T t in ts) {
stringBuilder.Append(t.ToString());
stringBuilder.Append(" ");
}
stringBuilder.Remove(stringBuilder.Length - 1, 1);
Console.WriteLine(stringBuilder.ToString());
}
public static void WriteToDebugConsole<T>(this IEnumerable<T> ts) {
StringBuilder stringBuilder = new StringBuilder();
foreach (T t in ts) {
stringBuilder.Append(t.ToString());
stringBuilder.Append(" ");
}
stringBuilder.Remove(stringBuilder.Length - 1, 1);
System.Diagnostics.Debug.WriteLine(stringBuilder.ToString());
}
}
|
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
| 8
| 751
| 4
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
int[] a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] a2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] a3 = Console.ReadLine().Split().Select(int.Parse).ToArray();
int n = int.Parse(Console.ReadLine());
int[] b = new int[n];
for (int i = 0; i < n; i++) {
b[i] = int.Parse(Console.ReadLine());
}
int[] ba1 = Enumerable.Repeat<int>(0, 3).ToArray();
int[] ba2 = Enumerable.Repeat<int>(0, 3).ToArray();
int[] ba3 = Enumerable.Repeat<int>(0, 3).ToArray();
for (int i = 0; i < n; i++) {
int num1 = Array.IndexOf(a1, b[i]);
if (num1 >= 0) {
ba1[num1] = 1;
}
int num2 = Array.IndexOf(a2, b[i]);
if (num2 >= 0) {
ba2[num2] = 1;
}
int num3 = Array.IndexOf(a3, b[i]);
if (num3 >= 0) {
ba3[num3] = 1;
}
}
int bingo = 0;
//横検索
if (ba1[0] == 1 && ba1[1] == 1 && ba1[2] == 1) {
bingo = 1;
}
if (ba2[0] == 1 && ba2[1] == 1 && ba2[2] == 1) {
bingo = 1;
}
if (ba3[0] == 1 && ba3[2] == 1 && ba3[2] == 1) {
bingo = 1;
}
//縦検索
if (ba1[0] == 1 && ba2[0] == 1 && ba3[0] == 1) {
bingo = 1;
}
if (ba1[1] == 1 && ba2[1] == 1 && ba3[1] == 1) {
bingo = 1;
}
if (ba1[2] == 1 && ba2[2] == 1 && ba3[2] == 1) {
bingo = 1;
}
//ななめ検索
if (ba1[0] == 1 && ba2[1] == 1 && ba3[2] == 1) {
bingo = 1;
}
if (ba1[2] == 1 && ba2[1] == 1 && ba3[0] == 1) {
bingo = 1;
}
if (bingo == 1) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
int[] a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] a2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] a3 = Console.ReadLine().Split().Select(int.Parse).ToArray();
int n = int.Parse(Console.ReadLine());
int[] b = new int[n];
for (int i = 0; i < n; i++) {
b[i] = int.Parse(Console.ReadLine());
}
int[] ba1 = Enumerable.Repeat<int>(0, 3).ToArray();
int[] ba2 = Enumerable.Repeat<int>(0, 3).ToArray();
int[] ba3 = Enumerable.Repeat<int>(0, 3).ToArray();
for (int i = 0; i < n; i++) {
int num1 = Array.IndexOf(a1, b[i]);
if (num1 >= 0) {
ba1[num1] = 1;
}
int num2 = Array.IndexOf(a2, b[i]);
if (num2 >= 0) {
ba2[num2] = 1;
}
int num3 = Array.IndexOf(a3, b[i]);
if (num3 >= 0) {
ba3[num3] = 1;
}
}
int bingo = 0;
//横検索
if (ba1[0] == 1 && ba1[1] == 1 && ba1[2] == 1) {
bingo = 1;
}
if (ba2[0] == 1 && ba2[1] == 1 && ba2[2] == 1) {
bingo = 1;
}
if (ba3[0] == 1 && ba3[1] == 1 && ba3[2] == 1) {
bingo = 1;
}
//縦検索
if (ba1[0] == 1 && ba2[0] == 1 && ba3[0] == 1) {
bingo = 1;
}
if (ba1[1] == 1 && ba2[1] == 1 && ba3[1] == 1) {
bingo = 1;
}
if (ba1[2] == 1 && ba2[2] == 1 && ba3[2] == 1) {
bingo = 1;
}
//ななめ検索
if (ba1[0] == 1 && ba2[1] == 1 && ba3[2] == 1) {
bingo = 1;
}
if (ba1[2] == 1 && ba2[1] == 1 && ba3[0] == 1) {
bingo = 1;
}
if (bingo == 1) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 614
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main() {
var a1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var a2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var a3 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var n = int.Parse(Console.ReadLine());
var a = a1.Concat(a2).Concat(a3).ToArray();
var bingo = new bool[a.Length];
for (int i = 0; i < n; i++) {
var b = int.Parse(Console.ReadLine());
for (int j = 0; j < a.Length; j++) {
if (a[j] == b) {
bingo[j] = true;
}
}
}
if (bingo[0] && bingo[1] && bingo[2] || bingo[3] && bingo[4] && bingo[5] ||
bingo[6] && bingo[7] && bingo[8] || bingo[0] && bingo[3] && bingo[6] ||
bingo[1] && bingo[4] && bingo[7] || bingo[2] && bingo[5] && bingo[8] ||
bingo[0] && bingo[4] && bingo[8] || bingo[2] && bingo[4] && bingo[7]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main() {
var a1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var a2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var a3 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var n = int.Parse(Console.ReadLine());
var a = a1.Concat(a2).Concat(a3).ToArray();
var bingo = new bool[a.Length];
for (int i = 0; i < n; i++) {
var b = int.Parse(Console.ReadLine());
for (int j = 0; j < a.Length; j++) {
if (a[j] == b) {
bingo[j] = true;
}
}
}
if (bingo[0] && bingo[1] && bingo[2] || bingo[3] && bingo[4] && bingo[5] ||
bingo[6] && bingo[7] && bingo[8] || bingo[0] && bingo[3] && bingo[6] ||
bingo[1] && bingo[4] && bingo[7] || bingo[2] && bingo[5] && bingo[8] ||
bingo[0] && bingo[4] && bingo[8] || bingo[2] && bingo[4] && bingo[6]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 367
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProgramingStudying2 {
class Program {
static void Main(string[] args) {
var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
var n = nm[0];
var m = nm[1];
var number = new int[n];
var visited = new bool[n];
for (int i = 0; i < m; i++) {
var sc = Console.ReadLine().Split();
var s = int.Parse(sc[0]);
var c = int.Parse(sc[1]);
if (visited[s - 1] && number[s - 1] != c) {
Console.WriteLine(-1);
return;
} else if (n > 1 && s == 1 && c == 0) {
Console.WriteLine(-1);
return;
} else {
visited[s - 1] = true;
number[s - 1] = c;
}
}
int ans = 0;
if (number[0] == 0) {
number[0] = 1;
}
for (int i = 0; i < n; i++) {
ans += number[i] * (int)Math.Pow(10, n - i - 1);
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProgramingStudying2 {
class Program {
static void Main(string[] args) {
var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
var n = nm[0];
var m = nm[1];
var number = new int[n];
var visited = new bool[n];
for (int i = 0; i < m; i++) {
var sc = Console.ReadLine().Split();
var s = int.Parse(sc[0]);
var c = int.Parse(sc[1]);
if (visited[s - 1] && number[s - 1] != c) {
Console.WriteLine(-1);
return;
} else if (n > 1 && s == 1 && c == 0) {
Console.WriteLine(-1);
return;
} else {
visited[s - 1] = true;
number[s - 1] = c;
}
}
var ans = 0;
if (n > 1 && number[0] == 0) {
number[0] = 1;
}
for (int i = 0; i < n; i++) {
ans += number[i] * (int)Math.Pow(10, n - i - 1);
}
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 299
| 6
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.