QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#343128#8247. ICPC Team GenerationElTeeran_ElHayga#WA 1ms3672kbC++201.6kb2024-03-01 22:48:132024-03-01 22:48:13

Judging History

你现在查看的是最新测评结果

  • [2024-03-01 22:48:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3672kb
  • [2024-03-01 22:48:13]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define fi first
#define se second
#define pp push_back
#define all(x) (x).begin(), (x).end()
#define Ones(n) __builtin_popcount(n)
#define endl '\n'
#define mem(arrr, xx) memset(arrr,xx,sizeof arrr)
//#define int long long
#define debug(x) cout << (#x) << " = " << x << endl

void Gamal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef Clion
    freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}

int dx[] = {+0, +0, -1, +1, +1, +1, -1, -1};
int dy[] = {-1, +1, +0, +0, +1, -1, +1, -1};

const double EPS = 1e-9;
const ll OO = 0X3F3F3F3F3F3F3F3F;
const int N = 50 + 5, INF = INT_MAX, MOD = 1e9 + 7, LOG = 20;

int dp[N], n;
pii a[N];

bool intersect(vector<int> x) {
    for (int i = 0; i < x.size(); ++i) {
        for (int j = 0; j < x.size(); ++j) {
            if(x[i] >= a[x[j]].fi && x[i] <= a[x[j]].se)continue;
            return false;
        }
    }
    return true;
}

int slv(int i) {
    if (i + 2 >= n)return 0;
    int &ret = dp[i];
    if (~ret)
        return ret;
    ret = slv(i + 1);
    if (intersect({i, i + 1 ,i + 2}))
        ret = max(ret, slv(i + 3) + 1);
    return ret;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].fi >> a[i].se;
    }
    sort(a, a + n);
    mem(dp, -1);
    cout << slv(0) << endl;
}


signed main() {
    Gamal();
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3508kb

input:

6
1 2
1 2
2 5
2 6
2 6
5 6

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

3
1 1
2 2
3 3

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

50
1 2
1 3
2 4
3 5
4 6
5 7
6 8
7 9
8 10
9 11
10 12
11 13
12 14
13 15
14 16
15 17
16 18
17 19
18 20
19 21
20 22
21 23
22 24
23 25
24 26
25 27
26 28
27 29
28 30
29 31
30 32
31 33
32 34
33 35
34 36
35 37
36 38
37 39
38 40
39 41
40 42
41 43
42 44
43 45
44 46
45 47
46 48
47 49
48 50
49 50

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50

output:

16

result:

ok single line: '16'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3672kb

input:

50
1 11
2 11
3 12
3 14
3 15
3 16
7 17
7 17
7 18
8 19
11 21
11 22
11 22
14 23
15 25
16 25
17 25
18 27
18 27
20 29
21 30
22 30
22 33
23 34
24 34
24 34
25 37
28 37
29 38
29 38
31 41
32 41
33 43
33 43
35 44
35 46
36 47
37 47
38 48
39 49
39 50
41 50
42 50
44 50
45 50
45 50
45 50
47 50
48 50
48 50

output:

1

result:

wrong answer 1st lines differ - expected: '7', found: '1'