結果

問題 No.2517 Right Triangles on Circle
ユーザー k82bk82b
提出日時 2023-10-28 00:32:12
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 1,065 bytes
コンパイル時間 5,441 ms
コンパイル使用メモリ 206,328 KB
実行使用メモリ 23,192 KB
最終ジャッジ日時 2023-10-28 00:32:24
合計ジャッジ時間 7,748 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 225 ms
22,972 KB
testcase_14 AC 222 ms
22,972 KB
testcase_15 AC 242 ms
23,164 KB
testcase_16 AC 180 ms
23,192 KB
testcase_17 AC 188 ms
21,084 KB
testcase_18 AC 171 ms
20,912 KB
testcase_19 AC 147 ms
16,828 KB
testcase_20 AC 150 ms
16,832 KB
testcase_21 AC 239 ms
23,000 KB
testcase_22 AC 56 ms
9,512 KB
testcase_23 AC 192 ms
19,008 KB
testcase_24 AC 69 ms
10,076 KB
testcase_25 AC 44 ms
7,256 KB
testcase_26 AC 195 ms
20,988 KB
testcase_27 AC 50 ms
9,488 KB
testcase_28 AC 26 ms
6,464 KB
testcase_29 AC 65 ms
10,004 KB
testcase_30 AC 37 ms
6,992 KB
testcase_31 AC 168 ms
18,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void main()
{
	const N = readInt;
	const M = readInt;
	auto A = new int[N];
	foreach (i; 0 .. N) {
		A[i] = readInt;
	}
	auto set = new RedBlackTree!(int, "a < b", false);
	foreach (i; 0 .. N) {
		set.insert(--A[i]);
	}
	long ans;
	foreach (i; 0 .. N) {
		if (((A[i] + M / 2) % M) in set) {
			ans += N - 2;
		}
	}
	ans /= 2;
	if (M % 2 == 1) ans = 0;
	writeln(ans);
}

import std,core.bitop;
string[]_R;
string readString(){while(_R.empty){_R=readln.chomp.split;}auto ret=_R.front;_R.popFront;return ret;}
int readInt(){return readString.to!int;}
long readLong(){return readString.to!long;}
ulong readULong(){return readString.to!ulong;}
real readReal(){return readString.to!real;}
bool chmin(T)(ref T A,T B){if(A>B){A=B;return true;}else{return false;}}
bool chmax(T)(ref T A,T B){if(A<B){A=B;return true;}else{return false;}}
int lowerBound(T)(T[]A,T x){int L=-1,R=cast(int)A.length;while(R-L>1){int mid=(L+R)/2;(A[mid]<x?L:R)=mid;}return R;}
int upperBound(T)(T[]A,T x){int L=-1,R=cast(int)A.length;while(R-L>1){int mid=(L+R)/2;(A[mid]<=x?L:R)=mid;}return R;}
0