Submission #10435013


Source Code Expand

Copy
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	int[] S, C;
	foreach(i; 0..M) {
		auto ip2 = readAs!(int[]), s = ip2[0], c = ip2[1];
		S ~= s;
		C ~= c;
	}
	foreach(i; 0..(10 ^^ (N))) {
		auto st = i.to!string;
		if(st.length != N) continue;
		bool flag = true;
		foreach(k; 0..M) {
			if(!(st[S[k]-1] - '0' == C[k])) flag = false;
		}
		if(flag) {
			writeln(i);
			return;
		}
	}
	writeln(-1);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Submission Info

Submission Time
Task C - Guess The Number
User private_yusuke
Language D (DMD64 v2.070.1)
Score 300
Code Size 1458 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 18
Set Name Test Cases
Sample 00-sample-00, 00-sample-01, 00-sample-02
All 00-sample-00, 00-sample-01, 00-sample-02, 01-handmade-00, 01-handmade-01, 01-handmade-02, 01-handmade-03, 01-handmade-04, 02-random-00, 02-random-01, 02-random-02, 02-random-03, 02-random-04, 02-random-05, 02-random-06, 02-random-07, 02-random-08, 02-random-09
Case Name Status Exec Time Memory
00-sample-00 AC 1 ms 256 KB
00-sample-01 AC 1 ms 256 KB
00-sample-02 AC 1 ms 256 KB
01-handmade-00 AC 1 ms 256 KB
01-handmade-01 AC 1 ms 256 KB
01-handmade-02 AC 1 ms 256 KB
01-handmade-03 AC 1 ms 256 KB
01-handmade-04 AC 1 ms 256 KB
02-random-00 AC 1 ms 256 KB
02-random-01 AC 1 ms 256 KB
02-random-02 AC 1 ms 256 KB
02-random-03 AC 1 ms 256 KB
02-random-04 AC 1 ms 256 KB
02-random-05 AC 1 ms 256 KB
02-random-06 AC 1 ms 256 KB
02-random-07 AC 1 ms 256 KB
02-random-08 AC 1 ms 256 KB
02-random-09 AC 1 ms 256 KB