結果

問題 No.1082 XORのXOR
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2020-06-22 00:50:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 4,171 bytes
コンパイル時間 2,540 ms
コンパイル使用メモリ 108,552 KB
実行使用メモリ 25,372 KB
最終ジャッジ日時 2023-09-16 19:00:23
合計ジャッジ時間 6,101 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,792 KB
testcase_01 AC 59 ms
20,716 KB
testcase_02 AC 60 ms
22,756 KB
testcase_03 AC 72 ms
23,084 KB
testcase_04 AC 72 ms
25,372 KB
testcase_05 AC 70 ms
21,120 KB
testcase_06 AC 71 ms
25,188 KB
testcase_07 AC 72 ms
25,204 KB
testcase_08 AC 71 ms
25,136 KB
testcase_09 AC 70 ms
21,268 KB
testcase_10 AC 72 ms
23,224 KB
testcase_11 AC 71 ms
25,212 KB
testcase_12 AC 70 ms
23,160 KB
testcase_13 AC 71 ms
23,156 KB
testcase_14 AC 71 ms
23,288 KB
testcase_15 AC 71 ms
23,376 KB
testcase_16 AC 71 ms
23,240 KB
testcase_17 AC 71 ms
23,332 KB
testcase_18 AC 71 ms
25,208 KB
testcase_19 AC 70 ms
23,276 KB
testcase_20 AC 72 ms
23,152 KB
testcase_21 AC 70 ms
23,284 KB
testcase_22 AC 70 ms
21,240 KB
testcase_23 AC 71 ms
23,092 KB
testcase_24 AC 71 ms
23,184 KB
testcase_25 AC 70 ms
23,288 KB
testcase_26 AC 71 ms
25,316 KB
testcase_27 AC 71 ms
25,200 KB
testcase_28 AC 60 ms
20,776 KB
testcase_29 AC 59 ms
22,920 KB
testcase_30 AC 59 ms
20,780 KB
testcase_31 AC 60 ms
22,888 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
using System.Runtime.Remoting.Messaging;
//using nint=System.Int32;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		var bt=new Bt();
		int ans=0;
		for(int i = 0;i<n;i++) {bt.Add(a[i]);}
		for(int i = 0;i<n;i++) {ans=Max(ans,(int)bt.Max(a[i]));}
		Console.WriteLine("{0}",ans);
	}
}
public class Bt{
	private const int b=30;
	private Nd r;
	public class Nd{
		public int d;
		public long n;
		public Nd[] h=new Nd[2];
		public override string ToString()=>"n:"+n.ToString()+" d:"+d.ToString();
	}
	public Bt(){
		r=new Nd();
	}
	public void Add(long n){
		var t=r;
		t.d++;
		for(int i = b;i>=0;i--) {
			long k=(n>>i)&1;
			t=t.h[k]==null?t.h[k]=new Nd():t.h[k];
			t.d++;
		}
		t.n=n;
	}
	public void Dl(long n){
		var t=r;
		t.d--;
		for(int i = b;i>=0;i--) {
			t=t.h[(n>>i)&1];
			t.d--;
		}
	}
	public long Ra(int n){
		if(n>r.d){return -1;}
		var t=r;
		for(int i = b;i>=0;i--) {
			if(t.h[0]==null){t=t.h[1];}
			else if(t.h[0].d<n){n-=t.h[0].d;t=t.h[1];}
			else{t=t.h[0];}
		}
		return t.n;
	}
	public long Lb(long n){return Flb(r,n,b,1);}
	private long Flb(Nd t,long n,int b,int o){
		if(b==-1){return t.d!=0?t.n:-1;}
		int k=(int)((n>>b)&o);
		if(t.h[k]!=null&&t.h[k].d!=0){
			var p=Flb(t.h[k],n,b-1,o);
			if(p!=-1){return p;}
		}
		if(k==0&&t.h[1]!=null&&t.h[1].d!=0){
			return Flb(t.h[1],n,b-1,0);
		}
		return -1;
	}
	public long Ub(long n){return Fub(r,n,b,0);}
	private long Fub(Nd t,long n,int b,int o){
		if(b==-1){return t.d!=0?t.n:-1;}
		int k=((int)((n>>b)&1))|o;
		if(t.h[k]!=null&&t.h[k].d!=0){
			var p=Fub(t.h[k],n,b-1,o);
			if(p!=-1){return p;}
		}
		if(k==1&&t.h[0]!=null&&t.h[0].d!=0){
			return Fub(t.h[0],n,b-1,1);
		}
		return -1;
	}
	public long Max(){
		var t=r;
		for(int i = b;i>=0;i--) {t=t.h[1]!=null&&t.h[1].d!=0?t.h[1]:t.h[0];}
		return t.n;
	}
	public long Min(){
		var t=r;
		for(int i = b;i>=0;i--) {t=t.h[0]!=null&&t.h[0].d!=0?t.h[0]:t.h[1];}
		return t.n;
	}
	public long Max(long x){
		var t=r;
		for(int i = b;i>=0;i--) {
			int k=(int)(((x>>i)^1)&1);
			t=t.h[k]!=null&&t.h[k].d!=0?t.h[k]:t.h[k^1];
		}
		return t.n^x;
	}
	public int cnt{get{return r.d;}}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}
0