Submission #850103

# Submission time Handle Problem Language Result Execution time Memory
850103 2023-09-15T18:14:31 Z alexdd Amusement Park (JOI17_amusement_park) C++17
28 / 100
30 ms 7724 KB
#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
static bool visited[10005];
static vector<int> ord;
static vector<int> con[10005];
static bool done[10005];
static void dfs(int nod)
{
    visited[nod]=1;
    sort(con[nod].begin(),con[nod].end());
    ord.push_back(nod);
    for(auto adj:con[nod])
    {
        if(!visited[adj])
        {
            dfs(adj);
            ord.push_back(nod);
        }
    }
}
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
    ord.clear();
    for(int i=0;i<N;i++)
    {
        visited[i]=0;
        con[i].clear();
        done[i]=0;
    }

    for(int i=0;i<M;i++)
    {
        con[A[i]].push_back(B[i]);
        con[B[i]].push_back(A[i]);
    }
    dfs(0);
    int cnt=0;
    for(int i=0;i<(int)ord.size();i++)
    {
        if(!done[ord[i]])
        {
            if(((1LL<<cnt)&X))
                MessageBoard(ord[i],1);
            else
                MessageBoard(ord[i],0);
            cnt=(cnt+1)%60;
            done[ord[i]]=1;
        }
    }
}


#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
static bool visited[10005];
static vector<int> ord;
static vector<int> con[10005];
static bool done[10005];
static int p[50005];
static int poz[10005];
static int fr[65];
static int care[10005];
static map<pair<int,int>,int> mp;
static void dfs(int nod)
{
    visited[nod]=1;
    sort(con[nod].begin(),con[nod].end());
    poz[nod]=ord.size();
    ord.push_back(nod);
    for(auto adj:con[nod])
    {
        if(!visited[adj])
        {
            dfs(adj);
            ord.push_back(nod);
        }
    }
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
    ord.clear();
    for(int i=0;i<N;i++)
    {
        visited[i]=0;
        con[i].clear();
        done[i]=0;
    }
    for(int i=0;i<60;i++)
        fr[i]=0;

    for(int i=0;i<M;i++)
    {
        con[A[i]].push_back(B[i]);
        con[B[i]].push_back(A[i]);
        mp[{A[i],B[i]}]++;
        mp[{B[i],A[i]}]++;
    }
    dfs(0);
    int cnt=0;
    for(int i=0;i<(int)ord.size();i++)
    {
        if(!done[ord[i]])
        {
            care[ord[i]]=cnt;
            cnt=(cnt+1)%60;
            done[ord[i]]=1;
        }
        p[i]=care[ord[i]];
    }
    long long rez=0;
    int cate=0;
    for(int i=poz[P];i<(int)ord.size();i++)
    {
        if(fr[p[i]]==0)
        {
            if(V==1) rez += (1LL<<(p[i]));
            fr[p[i]]=1;
            cate++;
            if(cate==60)
                return rez;
        }
        if(i+1<(int)ord.size())
        {
            if(mp[{ord[i],ord[i+1]}]==0)
                return -1;
            V = Move(ord[i+1]);
        }
    }
    for(int i=(int)ord.size()-1;i>=0;i--)
    {
        if(fr[p[i]]==0)
        {
            if(V==1) rez += (1LL<<(p[i]));
            fr[p[i]]=1;
            cate++;
            if(cate==60)
                return rez;
        }
        V = Move(ord[i-1]);
    }
    return rez;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 1296 KB Output is correct
2 Correct 1 ms 1300 KB Output is correct
3 Correct 2 ms 1300 KB Output is correct
4 Correct 1 ms 1312 KB Output is correct
5 Correct 1 ms 1308 KB Output is correct
6 Correct 1 ms 1312 KB Output is correct
7 Correct 2 ms 1312 KB Output is correct
8 Correct 2 ms 1304 KB Output is correct
9 Correct 2 ms 1308 KB Output is correct
10 Correct 1 ms 1300 KB Output is correct
11 Correct 5 ms 2140 KB Output is correct
12 Correct 1 ms 1308 KB Output is correct
13 Correct 2 ms 1312 KB Output is correct
14 Correct 2 ms 1340 KB Output is correct
15 Correct 2 ms 1316 KB Output is correct
16 Correct 2 ms 1308 KB Output is correct
17 Correct 2 ms 1300 KB Output is correct
18 Correct 1 ms 1308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 7276 KB Output is correct
2 Correct 27 ms 7684 KB Output is correct
3 Correct 30 ms 7672 KB Output is correct
4 Correct 16 ms 4668 KB Output is correct
5 Correct 18 ms 5324 KB Output is correct
6 Correct 16 ms 5188 KB Output is correct
7 Correct 16 ms 5184 KB Output is correct
8 Correct 18 ms 5288 KB Output is correct
9 Correct 16 ms 5184 KB Output is correct
10 Correct 15 ms 4756 KB Output is correct
11 Correct 15 ms 4672 KB Output is correct
12 Correct 13 ms 4652 KB Output is correct
13 Correct 13 ms 4460 KB Output is correct
14 Correct 15 ms 4680 KB Output is correct
15 Correct 16 ms 4684 KB Output is correct
16 Correct 17 ms 4676 KB Output is correct
17 Correct 16 ms 4992 KB Output is correct
18 Correct 16 ms 4764 KB Output is correct
19 Correct 15 ms 4980 KB Output is correct
20 Correct 13 ms 5168 KB Output is correct
21 Correct 13 ms 5296 KB Output is correct
22 Correct 16 ms 4952 KB Output is correct
23 Correct 16 ms 5208 KB Output is correct
24 Correct 16 ms 5196 KB Output is correct
25 Correct 16 ms 5188 KB Output is correct
26 Correct 16 ms 5188 KB Output is correct
27 Correct 16 ms 5188 KB Output is correct
28 Correct 16 ms 5184 KB Output is correct
29 Correct 13 ms 4664 KB Output is correct
30 Correct 15 ms 5184 KB Output is correct
31 Correct 1 ms 1300 KB Output is correct
32 Correct 1 ms 1300 KB Output is correct
33 Correct 2 ms 1316 KB Output is correct
34 Correct 1 ms 1312 KB Output is correct
35 Correct 2 ms 1300 KB Output is correct
36 Correct 1 ms 1296 KB Output is correct
37 Correct 2 ms 1280 KB Output is correct
38 Correct 1 ms 1312 KB Output is correct
39 Correct 1 ms 1312 KB Output is correct
40 Correct 2 ms 1312 KB Output is correct
41 Correct 1 ms 1300 KB Output is correct
42 Correct 1 ms 1312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1308 KB Output is correct
2 Correct 1 ms 1312 KB Output is correct
3 Correct 1 ms 1300 KB Output is correct
4 Correct 2 ms 2120 KB Output is correct
5 Correct 2 ms 2112 KB Output is correct
6 Correct 2 ms 2112 KB Output is correct
7 Correct 2 ms 2112 KB Output is correct
8 Correct 2 ms 2372 KB Output is correct
9 Correct 11 ms 5968 KB Output is correct
10 Correct 12 ms 5956 KB Output is correct
11 Correct 11 ms 5960 KB Output is correct
12 Correct 1 ms 1300 KB Output is correct
13 Correct 1 ms 1312 KB Output is correct
14 Correct 1 ms 1552 KB Output is correct
15 Correct 1 ms 1312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 7508 KB Output is correct
2 Correct 28 ms 7640 KB Output is correct
3 Partially correct 28 ms 7724 KB Partially correct
4 Correct 16 ms 4632 KB Output is correct
5 Partially correct 16 ms 5792 KB Partially correct
6 Correct 16 ms 5448 KB Output is correct
7 Correct 16 ms 5704 KB Output is correct
8 Correct 16 ms 4936 KB Output is correct
9 Correct 19 ms 5240 KB Output is correct
10 Correct 15 ms 4660 KB Output is correct
11 Correct 16 ms 4688 KB Output is correct
12 Correct 13 ms 4660 KB Output is correct
13 Correct 13 ms 4476 KB Output is correct
14 Correct 15 ms 4664 KB Output is correct
15 Correct 17 ms 4732 KB Output is correct
16 Correct 13 ms 4684 KB Output is correct
17 Correct 16 ms 4636 KB Output is correct
18 Correct 16 ms 4676 KB Output is correct
19 Correct 16 ms 4768 KB Output is correct
20 Incorrect 12 ms 5352 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 7256 KB Output is correct
2 Incorrect 28 ms 7716 KB Output isn't correct
3 Halted 0 ms 0 KB -