Submission #10452461


Source Code Expand

Copy
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, m;
	cin>>n>>m;
	bool zero=1;
	if(n>1) zero=0;
	int s[10], c[10];
	for(int i=0; i<m; i++){
		cin>>s[i]>>c[i];
		if(c[i]!=0) zero=0;
	}
	if(zero){
		cout<<0<<endl;
		return 0;
	}
	for(int i=1; i<1000; i++){
		int d=0;
		int x=i;
		int t[10];
		while(x){
			t[n-d]=x%10;
			x/=10; d++;
		}
		if(d!=n) continue;
		bool dame=0;
		for(int j=0; j<m; j++){
			if(t[s[j]]!=c[j]){
				dame=1;
			}
		}
		if(!dame){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Submission Info

Submission Time
Task C - Guess The Number
User chocorusk
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1104 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