Submission #1024356

# Submission time Handle Problem Language Result Execution time Memory
1024356 2024-07-16T01:30:34 Z 12345678 Fire (BOI24_fire) C++17
0 / 100
2000 ms 5724 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=4e5+5;

int n, m, s[nx], e[nx], p[nx], cur=1, res=1, st;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m;
    for (int i=1; i<=n; i++) 
    {
        cin>>s[i]>>e[i];
        if (s[i]>e[i]) e[i]+=m;
        s[i+n]=s[i]+m;
        e[i+n]=e[i]+m;
    }
    for (int i=1; i<=n; i++)
    {
        pair<int, int> mx={e[i], i};
        for (int j=1; j<=2*n; j++) if (s[j]<=e[i]) mx=max(mx, {e[j], (j>n)?(j-n):j});
        p[i]=mx.second;
    }
    //for (int i=1; i<=n; i++) cout<<i<<' '<<p[i]<<'\n';
    for (int i=1; i<=n; i++) cur=p[cur];
    st=cur;
    if (p[cur]==st) return cout<<-1, 0;
    while (p[cur]!=st) res++, cur=p[cur];
    cout<<res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Incorrect 1 ms 4444 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Incorrect 1 ms 4444 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Incorrect 1 ms 4444 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4556 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4500 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 73 ms 4664 KB Output is correct
16 Correct 69 ms 4636 KB Output is correct
17 Correct 81 ms 4444 KB Output is correct
18 Correct 80 ms 4440 KB Output is correct
19 Correct 69 ms 4664 KB Output is correct
20 Execution timed out 2079 ms 5724 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Incorrect 1 ms 4444 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Incorrect 1 ms 4444 KB Output isn't correct
4 Halted 0 ms 0 KB -