提出 #68198978


ソースコード 拡げる

using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Threading;
using static CpLibrary.StaticItems;
namespace CpLibrary.Contest
{
	public class SolverB : SolverBase
	{
		static void Main() => OnlineJudge.Run(new SolverB());

		public override void Solve()
		{
			var n = sr.ReadInt();
			var a = sr.ReadIntArray(n);
			var b = sr.ReadIntArray(n);
			var suma = a.Sum();
			var sumb = b.Sum();
			var ok = true;
			if (suma != sumb) ok = false;
			if (suma == 1)
			{
				if (a[0] == 1) ok = false;
				if (a[n - 1] == 1) ok = false;
				if (b[0] == 1) ok = false;
				if (b[n - 1] == 1) ok = false;

			}
			var ok2 = true;
			for (int i = 0; i < n; i++)
			{
				if (a[i] != b[i]) ok2 = false;
			}
			if (ok2) ok = true;
			sw.WriteLine(YesNo(ok));
		}

		public override void Init()
		{
			var t = sr.ReadInt();
			Testcases = t;
		}
	}
}
#region Expanded by https://github.com/kzrnm/SourceExpander
namespace CpLibrary { public abstract class SolverBase { public bool StartsOnThread { get; set; } = false; public int Testcases { get; set; } = 1;  public Scanner sr; public StreamWriter sw; public abstract void Init(); public abstract void Solve(); public void Run(StreamReader reader, StreamWriter writer) { this.sw = writer; sr = new Scanner(reader); Console.SetOut(writer); if (StartsOnThread) { var thread = new Thread(new ThreadStart(RunInternal), 1 << 27); thread.Start(); thread.Join(); } else { RunInternal(); } }  void RunInternal() { Init(); var testcases = Testcases; while (testcases-- > 0) { Solve(); } } }  public static partial class OnlineJudge { public static void Run(SolverBase solver) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; var sr = new StreamReader(Console.OpenStandardInput()); solver.Run(sr, sw); Console.Out.Flush(); } } }
namespace CpLibrary { public class Scanner { public StreamReader sr { get; private set; }  string[] str; int index; char[] separators; public Scanner(StreamReader sr, char[] separators) { this.sr = sr; this.separators = separators; str = new string[0]; index = 0; }  public Scanner(StreamReader sr) : this(sr, new char[] { ' ' }) { }  public Scanner() : this(new StreamReader(Console.OpenStandardInput()), new char[] { ' ' }) { }  public string Read() { if (index < str.Length) return str[index++]; string s; do s = sr.ReadLine(); while (s == ""); str = s.Split(separators, StringSplitOptions.RemoveEmptyEntries); index = 0; return str[index++]; }  public string ReadString() => Read(); public string[] ReadStringArray(int n) { var arr = new string[n]; for (int i = 0; i < n; i++) { arr[i] = ReadString(); }  return arr; }  public int ReadInt() => int.Parse(ReadString()); public int[] ReadIntArray(int n) => ReadValueArray<int>(n); public long ReadLong() => long.Parse(ReadString()); public long[] ReadLongArray(int n) => ReadValueArray<long>(n); public double ReadDouble() => double.Parse(ReadString()); public double[] ReadDoubleArray(int n) => ReadValueArray<double>(n); public BigInteger ReadBigInteger() => BigInteger.Parse(ReadString()); public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() => (ReadValue<T1>(), ReadValue<T2>()); public (T1, T2, T3) ReadValue<T1, T2, T3>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>()); public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>()); public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>(), ReadValue<T5>()); public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>(), ReadValue<T5>(), ReadValue<T6>()); public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>(), ReadValue<T5>(), ReadValue<T6>(), ReadValue<T7>()); public T1[] ReadValueArray<T1>(int n) { var arr = new T1[n]; for (int i = 0; i < n; i++) { arr[i] = ReadValue<T1>(); }  return arr; }  public (T1[], T2[]) ReadValueArray<T1, T2>(int n) { var(v1, v2) = (new T1[n], new T2[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i]) = ReadValue<T1, T2>(); }  return (v1, v2); }  public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int n) { var(v1, v2, v3) = (new T1[n], new T2[n], new T3[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i]) = ReadValue<T1, T2, T3>(); }  return (v1, v2, v3); }  public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int n) { var(v1, v2, v3, v4) = (new T1[n], new T2[n], new T3[n], new T4[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i]) = ReadValue<T1, T2, T3, T4>(); }  return (v1, v2, v3, v4); }  public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int n) { var(v1, v2, v3, v4, v5) = (new T1[n], new T2[n], new T3[n], new T4[n], new T5[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i], v5[i]) = ReadValue<T1, T2, T3, T4, T5>(); }  return (v1, v2, v3, v4, v5); }  public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int n) { var(v1, v2, v3, v4, v5, v6) = (new T1[n], new T2[n], new T3[n], new T4[n], new T5[n], new T6[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i], v5[i], v6[i]) = ReadValue<T1, T2, T3, T4, T5, T6>(); }  return (v1, v2, v3, v4, v5, v6); }  public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int n) { var(v1, v2, v3, v4, v5, v6, v7) = (new T1[n], new T2[n], new T3[n], new T4[n], new T5[n], new T6[n], new T7[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i], v5[i], v6[i], v7[i]) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); }  return (v1, v2, v3, v4, v5, v6, v7); }  public (T1, T2)[] ReadTupleArray<T1, T2>(int n) { var ret = new (T1, T2)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2>(); }  return ret; }  public (T1, T2, T3)[] ReadTupleArray<T1, T2, T3>(int n) { var ret = new (T1, T2, T3)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3>(); }  return ret; }  public (T1, T2, T3, T4)[] ReadTupleArray<T1, T2, T3, T4>(int n) { var ret = new (T1, T2, T3, T4)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4>(); }  return ret; }  public (T1, T2, T3, T4, T5)[] ReadTupleArray<T1, T2, T3, T4, T5>(int n) { var ret = new (T1, T2, T3, T4, T5)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4, T5>(); }  return ret; }  public (T1, T2, T3, T4, T5, T6)[] ReadTupleArray<T1, T2, T3, T4, T5, T6>(int n) { var ret = new (T1, T2, T3, T4, T5, T6)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4, T5, T6>(); }  return ret; }  public (T1, T2, T3, T4, T5, T6, T7)[] ReadTupleArray<T1, T2, T3, T4, T5, T6, T7>(int n) { var ret = new (T1, T2, T3, T4, T5, T6, T7)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); }  return ret; } } }
namespace CpLibrary { public static partial class StaticItems { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int PopCount(uint n) { n = (n & 0x55555555) + (n >> 1 & 0x55555555); n = (n & 0x33333333) + (n >> 2 & 0x33333333); n = (n & 0x0f0f0f0f) + (n >> 4 & 0x0f0f0f0f); n = (n & 0x00ff00ff) + (n >> 8 & 0x00ff00ff); n = (n & 0x0000ffff) + (n >> 16 & 0x0000ffff); return (int)n; }  [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int PopCount(int n) => PopCount((uint)n); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int PopCount(ulong n) { n = (n & 0x5555555555555555) + (n >> 1 & 0x5555555555555555); n = (n & 0x3333333333333333) + (n >> 2 & 0x3333333333333333); n = (n & 0x0f0f0f0f0f0f0f0f) + (n >> 4 & 0x0f0f0f0f0f0f0f0f); n = (n & 0x00ff00ff00ff00ff) + (n >> 8 & 0x00ff00ff00ff00ff); n = (n & 0x0000ffff0000ffff) + (n >> 16 & 0x0000ffff0000ffff); n = (n & 0x00000000ffffffff) + (n >> 32 & 0x00000000ffffffff); return (int)n; }  [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int PopCount(long n) => PopCount((ulong)n); } }
namespace CpLibrary { public static partial class StaticItems { public static int[] dx4 => new int[] { 1, 0, -1, 0 }; public static int[] dy4 => new int[] { 0, 1, 0, -1 }; public static int[] dx8 => new int[] { 1, 1, 0, -1, -1, -1, 0, 1 }; public static int[] dy8 => new int[] { 0, 1, 1, 1, 0, -1, -1, -1 };  public enum YesNoOption { Normal, Upper, Lower }  public static string YesNo(bool condition, YesNoOption option = YesNoOption.Normal) { if (option == YesNoOption.Normal) return YesNoNormal(condition); else if (option == YesNoOption.Upper) return YesNoUpper(condition); else if (option == YesNoOption.Lower) return YesNoLower(condition); else throw new ArgumentException(); }  public static string YesNoNormal(bool condition) => condition ? "Yes" : "No"; public static string YesNoUpper(bool condition) => condition ? "YES" : "NO"; public static string YesNoLower(bool condition) => condition ? "yes" : "no"; public static T SignOutput<T>(int x, T pos, T zero, T neg) => x == 0 ? zero : (x > 0 ? pos : neg); public static T SignOutput<T>(long x, T pos, T zero, T neg) => x == 0 ? zero : (x > 0 ? pos : neg); public static T SignOutput<T>(double x, T pos, T zero, T neg) => x == 0 ? zero : (x > 0 ? pos : neg); public static T[] CreateArray<T>(int n, Func<int, T> func) => Enumerable.Range(0, n).Select(p => func(p)).ToArray(); public static T[][] CreateArray<T>(int x, int y, Func<int, int, T> func) => Enumerable.Range(0, x).Select(i => Enumerable.Range(0, y).Select(j => func(i, j)).ToArray()).ToArray(); public static T[][][] CreateArray<T>(int x, int y, int z, Func<int, int, int, T> func) => Enumerable.Range(0, x).Select(i => Enumerable.Range(0, y).Select(j => Enumerable.Range(0, z).Select(k => func(i, j, k)).ToArray()).ToArray()).ToArray(); } }
#endregion Expanded by https://github.com/kzrnm/SourceExpander

提出情報

提出日時
問題 B - Swap If Equal Sum
ユーザ fairy_lettuce
言語 C# 11.0 (.NET 7.0.7)
得点 500
コード長 9986 Byte
結果 AC
実行時間 108 ms
メモリ 54636 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 1
AC × 58
セット名 テストケース
Sample sample.txt
All 1_1.txt, 1_10.txt, 1_2.txt, 1_3.txt, 1_4.txt, 1_5.txt, 1_6.txt, 1_7.txt, 1_8.txt, 1_9.txt, 2_1.txt, 2_10.txt, 2_2.txt, 2_3.txt, 2_4.txt, 2_5.txt, 2_6.txt, 2_7.txt, 2_8.txt, 2_9.txt, 3_1.txt, 3_10.txt, 3_11.txt, 3_12.txt, 3_13.txt, 3_14.txt, 3_15.txt, 3_16.txt, 3_17.txt, 3_18.txt, 3_19.txt, 3_2.txt, 3_20.txt, 3_3.txt, 3_4.txt, 3_5.txt, 3_6.txt, 3_7.txt, 3_8.txt, 3_9.txt, 4_1.txt, 4_10.txt, 4_11.txt, 4_12.txt, 4_13.txt, 4_14.txt, 4_15.txt, 4_16.txt, 4_2.txt, 4_3.txt, 4_4.txt, 4_5.txt, 4_6.txt, 4_7.txt, 4_8.txt, 4_9.txt, 5.txt, sample.txt
ケース名 結果 実行時間 メモリ
1_1.txt AC 94 ms 52376 KiB
1_10.txt AC 94 ms 49356 KiB
1_2.txt AC 91 ms 54564 KiB
1_3.txt AC 93 ms 52464 KiB
1_4.txt AC 92 ms 53692 KiB
1_5.txt AC 81 ms 54408 KiB
1_6.txt AC 88 ms 52448 KiB
1_7.txt AC 88 ms 54000 KiB
1_8.txt AC 92 ms 53788 KiB
1_9.txt AC 90 ms 51916 KiB
2_1.txt AC 82 ms 52484 KiB
2_10.txt AC 78 ms 52244 KiB
2_2.txt AC 92 ms 52460 KiB
2_3.txt AC 86 ms 52364 KiB
2_4.txt AC 87 ms 52168 KiB
2_5.txt AC 87 ms 52164 KiB
2_6.txt AC 90 ms 52476 KiB
2_7.txt AC 85 ms 52228 KiB
2_8.txt AC 88 ms 52144 KiB
2_9.txt AC 81 ms 52396 KiB
3_1.txt AC 85 ms 54144 KiB
3_10.txt AC 84 ms 54372 KiB
3_11.txt AC 88 ms 54320 KiB
3_12.txt AC 81 ms 54220 KiB
3_13.txt AC 84 ms 54204 KiB
3_14.txt AC 86 ms 54392 KiB
3_15.txt AC 86 ms 54216 KiB
3_16.txt AC 90 ms 54452 KiB
3_17.txt AC 90 ms 54444 KiB
3_18.txt AC 84 ms 54212 KiB
3_19.txt AC 86 ms 54636 KiB
3_2.txt AC 85 ms 54020 KiB
3_20.txt AC 88 ms 54496 KiB
3_3.txt AC 79 ms 54380 KiB
3_4.txt AC 81 ms 54448 KiB
3_5.txt AC 89 ms 54104 KiB
3_6.txt AC 91 ms 54308 KiB
3_7.txt AC 91 ms 54368 KiB
3_8.txt AC 84 ms 54160 KiB
3_9.txt AC 91 ms 54236 KiB
4_1.txt AC 95 ms 53828 KiB
4_10.txt AC 96 ms 53688 KiB
4_11.txt AC 96 ms 53720 KiB
4_12.txt AC 90 ms 53840 KiB
4_13.txt AC 91 ms 54044 KiB
4_14.txt AC 90 ms 53720 KiB
4_15.txt AC 93 ms 54028 KiB
4_16.txt AC 58 ms 30564 KiB
4_2.txt AC 95 ms 53980 KiB
4_3.txt AC 89 ms 53684 KiB
4_4.txt AC 89 ms 53740 KiB
4_5.txt AC 97 ms 53636 KiB
4_6.txt AC 96 ms 53912 KiB
4_7.txt AC 92 ms 53876 KiB
4_8.txt AC 93 ms 53748 KiB
4_9.txt AC 89 ms 53736 KiB
5.txt AC 108 ms 53696 KiB
sample.txt AC 46 ms 25760 KiB