hiho week 30 register

Ended

Participants:387

Verdict:Accepted
Score:100 / 100
Submitted:2015-01-26 18:46:45

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cstdio>
using namespace std;
const int MAX = 100000+10;
int a[2][MAX],b[MAX];
int res[2][MAX];
bool trycase(int num, int idx, int len)
{
    a[idx][1] = num;
    if (a[idx][1]<0 || a[idx][1]>1)
        return false;
    a[idx][2] = b[1]-a[idx][1];
    if (a[idx][2]<0 || a[idx][2]>1)
        return false;
    for (int i = 3; i <= len; ++i)
    {
        a[idx][i] = b[i-1]-a[idx][i-1]-a[idx][i-2];
        if (a[idx][i]<0 || a[idx][i]>1)
            return false;
    }
    if (a[idx][len]+a[idx][len-1] != b[len])
        return false;
    else 
        return true;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX