Submission #10437521
Source Code Expand
Copy
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
const int maxN = 1 << 17;
bool vis[maxN];
char out[maxN];
void solve()
{
int n, m;
scanf ("%d%d", &n, &m);
out[n] = 0;
bool fail = false;
while (m--)
{
int a, b;
scanf ("%d%d", &a, &b);
a--;
if (vis[a] and (out[a] - '0') != b)
fail = true;
else
out[a] = ('0' + b), vis[a] = true;
}
if (n != 1 and vis[0] and out[0] == '0')
fail = true;
FOR(i, 0, n)
if (!vis[i])
out[i] = i == 0 ? '1' : '0';
if (fail)
printf("-1\n");
else
printf("%s\n", out);
}
int main()
{
int t;
t = 1;//scanf ("%d", &t);
while (t--)
solve();
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Guess The Number |
User |
bgrm |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1124 Byte |
Status |
WA |
Exec Time |
1 ms |
Memory |
256 KB |
Compile Error
./Main.cpp: In function ‘void solve()’:
./Main.cpp:27:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d%d", &n, &m);
^
./Main.cpp:33:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d%d", &a, &b);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 300 |
Status |
|
|
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 |
WA |
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 |