Submission #993056

# Submission time Handle Problem Language Result Execution time Memory
993056 2024-06-05T09:24:48 Z thelegendary08 September (APIO24_september) C++17
100 / 100
137 ms 12232 KB
#include "september.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define ll long long int
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vpll vector<pair<long long int, long long int>>
#define pqpll priority_queue<pair<long long int, long long int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define mii map<int,int>
#define mll map<long long int, long long int>
#define mivi map<int,vector<int>>
#define f0r(i,n) for(int i=0;i<n;i++)
#define FOR(i,k,n) for(int i=k;i<n;i++)
using namespace __gnu_pbds;
using namespace std;

int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
    int ans = 0;
    vvi nxt(N, vector<int>());
    f0r(i, N){
        if(i != 0)nxt[F[i]].pb(i);
    }

    vb vis(N, false);
    vector<set<int>>pending(M);
    queue<int>q;
    f0r(i, N-1){
        f0r(j, M){
            if(vis[S[j][i]]){
                pending[j].erase(S[j][i]);
            }
            else{
                q.push(S[j][i]);
                vis[S[j][i]] = 1;
                f0r(k, M)if(j != k)pending[k].insert(S[j][i]);
                while(!q.empty()){
                    int cur = q.front();
                    q.pop();
                    for(auto u : nxt[cur]){
                        if(vis[u])continue;
                        f0r(k, M)pending[k].insert(u);
                        vis[u] = 1;
                        q.push(u);
                    }
                }
            }

        }
        bool ok = 1;

        f0r(j,M)if(!pending[j].empty())ok = 0;
        if(ok)ans++;
    }
    /*

    vi v = S[0];

    int lo = N;
    int ans = 0;
    f0r(i, N-1){
        //cout<<i<<'\n';

        if(v[i] < lo){
            for(int j = v[i]+1;j<lo;j++)pending.insert(j);
            lo = v[i];
        }
        else{
            pending.erase(v[i]);
        }

        if(pending.empty())ans++;
    }
    */
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 119 ms 10152 KB Output is correct
5 Correct 136 ms 10368 KB Output is correct
6 Correct 120 ms 10184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 119 ms 10152 KB Output is correct
19 Correct 136 ms 10368 KB Output is correct
20 Correct 120 ms 10184 KB Output is correct
21 Correct 135 ms 8580 KB Output is correct
22 Correct 137 ms 8436 KB Output is correct
23 Correct 130 ms 10020 KB Output is correct
24 Correct 130 ms 9348 KB Output is correct
25 Correct 129 ms 9596 KB Output is correct
26 Correct 134 ms 9288 KB Output is correct
27 Correct 127 ms 7108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 119 ms 10152 KB Output is correct
8 Correct 136 ms 10368 KB Output is correct
9 Correct 120 ms 10184 KB Output is correct
10 Correct 77 ms 10948 KB Output is correct
11 Correct 79 ms 11212 KB Output is correct
12 Correct 76 ms 12232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 119 ms 10152 KB Output is correct
36 Correct 136 ms 10368 KB Output is correct
37 Correct 120 ms 10184 KB Output is correct
38 Correct 135 ms 8580 KB Output is correct
39 Correct 137 ms 8436 KB Output is correct
40 Correct 130 ms 10020 KB Output is correct
41 Correct 130 ms 9348 KB Output is correct
42 Correct 129 ms 9596 KB Output is correct
43 Correct 134 ms 9288 KB Output is correct
44 Correct 127 ms 7108 KB Output is correct
45 Correct 77 ms 10948 KB Output is correct
46 Correct 79 ms 11212 KB Output is correct
47 Correct 76 ms 12232 KB Output is correct
48 Correct 87 ms 10700 KB Output is correct
49 Correct 86 ms 10704 KB Output is correct
50 Correct 87 ms 10436 KB Output is correct
51 Correct 96 ms 11068 KB Output is correct
52 Correct 85 ms 10696 KB Output is correct
53 Correct 87 ms 10600 KB Output is correct
54 Correct 85 ms 11204 KB Output is correct