Submission #1367706
Source Code Expand
import std.stdio; import std.string; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.ascii; import std.concurrency; void times(alias fun)(int n) { foreach(i; 0..n) fun(); } auto rep(alias fun, T = typeof(fun()))(int n) { T[] res = new T[n]; foreach(ref e; res) e = fun(); return res; } void main() { int N, M; readf("%d %d\n", &N, &M); bool[][] mat = new bool[][](N, N); foreach(i; 0..N) { mat[i][i] = true; } foreach(_; 0..M) { int x, y; readf("%d %d\n", &x, &y); x--; y--; mat[x][y] = true; mat[y][x] = true; } long ans = 0; foreach(i; 0..2^^N) { long s = 0; bool flg = true; foreach(j; 0..N) { if (i>>j&1) s++; foreach(k; 0..j) { if ((i>>j&1) && (i>>k&1)) { if (!mat[j][k]) flg = false; } } } if (flg) ans = max(ans, s); } ans.writeln; } // ---------------------------------------------- // fold was added in D 2.071.0 static if (__VERSION__ < 2071) { template fold(fun...) if (fun.length >= 1) { auto fold(R, S...)(R r, S seed) { static if (S.length < 2) { return reduce!fun(seed, r); } else { return reduce!fun(tuple(seed), r); } } } } // cumulativeFold was added in D 2.072.0 static if (__VERSION__ < 2072) { template cumulativeFold(fun...) if (fun.length >= 1) { import std.meta : staticMap; private alias binfuns = staticMap!(binaryFun, fun); auto cumulativeFold(R)(R range) if (isInputRange!(Unqual!R)) { return cumulativeFoldImpl(range); } auto cumulativeFold(R, S)(R range, S seed) if (isInputRange!(Unqual!R)) { static if (fun.length == 1) return cumulativeFoldImpl(range, seed); else return cumulativeFoldImpl(range, seed.expand); } private auto cumulativeFoldImpl(R, Args...)(R range, ref Args args) { import std.algorithm.internal : algoFormat; static assert(Args.length == 0 || Args.length == fun.length, algoFormat("Seed %s does not have the correct amount of fields (should be %s)", Args.stringof, fun.length)); static if (args.length) alias State = staticMap!(Unqual, Args); else alias State = staticMap!(ReduceSeedType!(ElementType!R), binfuns); foreach (i, f; binfuns) { static assert(!__traits(compiles, f(args[i], e)) || __traits(compiles, { args[i] = f(args[i], e); }()), algoFormat("Incompatible function/seed/element: %s/%s/%s", fullyQualifiedName!f, Args[i].stringof, E.stringof)); } static struct Result { private: R source; State state; this(R range, ref Args args) { source = range; if (source.empty) return; foreach (i, f; binfuns) { static if (args.length) state[i] = f(args[i], source.front); else state[i] = source.front; } } public: @property bool empty() { return source.empty; } @property auto front() { assert(!empty, "Attempting to fetch the front of an empty cumulativeFold."); static if (fun.length > 1) { import std.typecons : tuple; return tuple(state); } else { return state[0]; } } void popFront() { assert(!empty, "Attempting to popFront an empty cumulativeFold."); source.popFront; if (source.empty) return; foreach (i, f; binfuns) state[i] = f(state[i], source.front); } static if (isForwardRange!R) { @property auto save() { auto result = this; result.source = source.save; return result; } } static if (hasLength!R) { @property size_t length() { return source.length; } } } return Result(range, args); } } } // minElement/maxElement was added in D 2.072.0 static if (__VERSION__ < 2072) { auto minElement(alias map, Range)(Range r) if (isInputRange!Range && !isInfinite!Range) { alias mapFun = unaryFun!map; auto element = r.front; auto minimum = mapFun(element); r.popFront; foreach(a; r) { auto b = mapFun(a); if (b < minimum) { element = a; minimum = b; } } return element; } auto maxElement(alias map, Range)(Range r) if (isInputRange!Range && !isInfinite!Range) { alias mapFun = unaryFun!map; auto element = r.front; auto maximum = mapFun(element); r.popFront; foreach(a; r) { auto b = mapFun(a); if (b > maximum) { element = a; maximum = b; } } return element; } }
Submission Info
Submission Time | |
---|---|
Task | D - 派閥 |
User | arkark |
Language | D (DMD64 v2.070.1) |
Score | 100 |
Code Size | 6460 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 KB |
Judge Result
Set Name | all | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
all | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt, test_59.txt, test_60.txt, test_61.txt, test_62.txt, test_63.txt, test_64.txt, test_65.txt, test_66.txt, test_67.txt, test_68.txt, test_69.txt, test_70.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 1 ms | 256 KB |
00_sample_02.txt | AC | 1 ms | 256 KB |
00_sample_03.txt | AC | 1 ms | 256 KB |
00_sample_04.txt | AC | 2 ms | 256 KB |
test_01.txt | AC | 1 ms | 256 KB |
test_02.txt | AC | 1 ms | 256 KB |
test_03.txt | AC | 1 ms | 256 KB |
test_04.txt | AC | 1 ms | 256 KB |
test_05.txt | AC | 1 ms | 256 KB |
test_06.txt | AC | 1 ms | 256 KB |
test_07.txt | AC | 1 ms | 256 KB |
test_08.txt | AC | 1 ms | 256 KB |
test_09.txt | AC | 1 ms | 256 KB |
test_10.txt | AC | 1 ms | 256 KB |
test_11.txt | AC | 2 ms | 256 KB |
test_12.txt | AC | 2 ms | 256 KB |
test_13.txt | AC | 1 ms | 256 KB |
test_14.txt | AC | 1 ms | 256 KB |
test_15.txt | AC | 1 ms | 256 KB |
test_16.txt | AC | 1 ms | 256 KB |
test_17.txt | AC | 1 ms | 256 KB |
test_18.txt | AC | 2 ms | 256 KB |
test_19.txt | AC | 2 ms | 256 KB |
test_20.txt | AC | 2 ms | 256 KB |
test_21.txt | AC | 1 ms | 256 KB |
test_22.txt | AC | 2 ms | 256 KB |
test_23.txt | AC | 1 ms | 256 KB |
test_24.txt | AC | 2 ms | 256 KB |
test_25.txt | AC | 1 ms | 256 KB |
test_26.txt | AC | 2 ms | 256 KB |
test_27.txt | AC | 1 ms | 256 KB |
test_28.txt | AC | 1 ms | 256 KB |
test_29.txt | AC | 1 ms | 256 KB |
test_30.txt | AC | 1 ms | 256 KB |
test_31.txt | AC | 2 ms | 256 KB |
test_32.txt | AC | 2 ms | 256 KB |
test_33.txt | AC | 2 ms | 256 KB |
test_34.txt | AC | 1 ms | 256 KB |
test_35.txt | AC | 2 ms | 256 KB |
test_36.txt | AC | 2 ms | 256 KB |
test_37.txt | AC | 2 ms | 256 KB |
test_38.txt | AC | 2 ms | 256 KB |
test_39.txt | AC | 2 ms | 256 KB |
test_40.txt | AC | 2 ms | 256 KB |
test_41.txt | AC | 2 ms | 256 KB |
test_42.txt | AC | 2 ms | 256 KB |
test_43.txt | AC | 2 ms | 256 KB |
test_44.txt | AC | 2 ms | 256 KB |
test_45.txt | AC | 2 ms | 256 KB |
test_46.txt | AC | 2 ms | 256 KB |
test_47.txt | AC | 2 ms | 256 KB |
test_48.txt | AC | 2 ms | 256 KB |
test_49.txt | AC | 2 ms | 256 KB |
test_50.txt | AC | 2 ms | 256 KB |
test_51.txt | AC | 2 ms | 256 KB |
test_52.txt | AC | 2 ms | 256 KB |
test_53.txt | AC | 2 ms | 256 KB |
test_54.txt | AC | 2 ms | 256 KB |
test_55.txt | AC | 2 ms | 256 KB |
test_56.txt | AC | 2 ms | 256 KB |
test_57.txt | AC | 2 ms | 256 KB |
test_58.txt | AC | 2 ms | 256 KB |
test_59.txt | AC | 2 ms | 256 KB |
test_60.txt | AC | 2 ms | 256 KB |
test_61.txt | AC | 2 ms | 256 KB |
test_62.txt | AC | 1 ms | 256 KB |
test_63.txt | AC | 2 ms | 256 KB |
test_64.txt | AC | 2 ms | 256 KB |
test_65.txt | AC | 2 ms | 256 KB |
test_66.txt | AC | 2 ms | 256 KB |
test_67.txt | AC | 2 ms | 256 KB |
test_68.txt | AC | 2 ms | 256 KB |
test_69.txt | AC | 2 ms | 256 KB |
test_70.txt | AC | 2 ms | 256 KB |