[Offer收割]编程练习赛51 register

Ended

Participants:280

Verdict:Wrong Answer
Score:0 / 100
Submitted:2018-03-18 13:46:10

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<iostream>
using namespace std;
struct block
{
    int s, e, index;
    block(int a = 0, int b = 0, int c = 0) :s(a), e(b), index(c) {}
};
block blo[1010];
int cnt = 0, cur = 0;
void inser(int a, int b)
{
    block k(a, b, ++cnt);
    int i;
    for (i = 0; i < cur; i++)
    {
        if (blo[i].s > k.s)
        {
            while (i > 0 && i < cur&& blo[i].s == blo[i - 1].e + 1)
                i++;
            break;
        }
    }
    for (int j = cur - 1; j >= i; j--)
        blo[j + 1] = blo[j];
    blo[i] = k;
    cur++;
    for (int j = i; j < cur; j++)
    {
        if (j > 0 && blo[j].s <= blo[j - 1].e)
        {
            blo[j].e += blo[j - 1].e + 1 - blo[j].s;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX