Submission #995300

# Submission time Handle Problem Language Result Execution time Memory
995300 2024-06-08T19:27:03 Z idk__ September (APIO24_september) C++17
16 / 100
231 ms 46296 KB
#include "september.h"
#include <bits/stdc++.h>
using namespace std;



int vis[200055];
vector<int>adj[200055];
vector<int>idx[200055];
bool flag = false;
int pos[20055];
int dfs(int i ){    
    int curr = pos[i];
    vis[i]=1;
    for(auto j : adj[i]){
        if(!vis[j]){
            curr = max(curr, dfs(j));
        }
    }
    
    return curr;
}
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
    //return 5;
    memset(vis, 0, sizeof vis);
    memset(idx, 0, sizeof idx);
    memset(pos, 0, sizeof pos);
    for(int i = 0;i < 2055; i++)if(adj[i].size())adj[i].clear();
    for(int i = 1;i < F.size(); i++){
        //adj[i].push_back(F[i]);
        adj[F[i]].push_back(i);
    
    }
    for(auto i : S[0]){
        pos[S[0][i]] = i;
    }
    vector<int>vec;
    for(auto i : S[0])vec.push_back(i);
    int cnt = 0;
    for(int i = 0;i < vec.size(); i++){
        
        int y = 0;
        if(vec[i]==1)flag = true;
        int R_ind = dfs(vec[i]);
        if(vec[i]==1){
            //cout << R_ind << " ";
        }
        for(int j = i+1; j<=R_ind; j++){
            R_ind = max(R_ind, dfs(vec[j]));
            }

        i = max(i, R_ind);
        cnt++;
    

        
        

    }
    return cnt;
    
}

  

Compilation message

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:26:30: warning: 'void* memset(void*, int, size_t)' clearing an object of type 'class std::vector<int>' with no trivial copy-assignment; use assignment or value-initialization instead [-Wclass-memaccess]
   26 |     memset(idx, 0, sizeof idx);
      |                              ^
In file included from /usr/include/c++/10/vector:67,
                 from september.h:1,
                 from september.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'class std::vector<int>' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
september.cpp:29:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 1;i < F.size(); i++){
      |                   ~~^~~~~~~~~~
september.cpp:40:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i = 0;i < vec.size(); i++){
      |                   ~~^~~~~~~~~~~~
september.cpp:42:13: warning: unused variable 'y' [-Wunused-variable]
   42 |         int y = 0;
      |             ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10584 KB Output is correct
2 Correct 3 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 4 ms 10588 KB Output is correct
5 Correct 3 ms 10588 KB Output is correct
6 Correct 3 ms 10588 KB Output is correct
7 Correct 3 ms 10588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10584 KB Output is correct
2 Correct 3 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 4 ms 10588 KB Output is correct
5 Correct 3 ms 10588 KB Output is correct
6 Correct 3 ms 10588 KB Output is correct
7 Correct 3 ms 10588 KB Output is correct
8 Incorrect 3 ms 10584 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 10588 KB Output is correct
2 Correct 10 ms 10588 KB Output is correct
3 Correct 9 ms 10640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10584 KB Output is correct
2 Correct 3 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 4 ms 10588 KB Output is correct
5 Correct 3 ms 10588 KB Output is correct
6 Correct 3 ms 10588 KB Output is correct
7 Correct 3 ms 10588 KB Output is correct
8 Correct 8 ms 10588 KB Output is correct
9 Correct 10 ms 10588 KB Output is correct
10 Correct 9 ms 10640 KB Output is correct
11 Correct 8 ms 10588 KB Output is correct
12 Incorrect 8 ms 10588 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 10588 KB Output is correct
2 Correct 10 ms 10588 KB Output is correct
3 Correct 9 ms 10640 KB Output is correct
4 Incorrect 9 ms 10584 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10584 KB Output is correct
2 Correct 3 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 4 ms 10588 KB Output is correct
5 Correct 3 ms 10588 KB Output is correct
6 Correct 3 ms 10588 KB Output is correct
7 Correct 3 ms 10588 KB Output is correct
8 Incorrect 3 ms 10584 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 10588 KB Output is correct
2 Correct 10 ms 10588 KB Output is correct
3 Correct 9 ms 10640 KB Output is correct
4 Runtime error 231 ms 46296 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10584 KB Output is correct
2 Correct 3 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 4 ms 10588 KB Output is correct
5 Correct 3 ms 10588 KB Output is correct
6 Correct 3 ms 10588 KB Output is correct
7 Correct 3 ms 10588 KB Output is correct
8 Correct 8 ms 10588 KB Output is correct
9 Correct 10 ms 10588 KB Output is correct
10 Correct 9 ms 10640 KB Output is correct
11 Correct 8 ms 10588 KB Output is correct
12 Incorrect 8 ms 10588 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 10588 KB Output is correct
2 Correct 10 ms 10588 KB Output is correct
3 Correct 9 ms 10640 KB Output is correct
4 Incorrect 9 ms 10584 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10584 KB Output is correct
2 Correct 3 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 4 ms 10588 KB Output is correct
5 Correct 3 ms 10588 KB Output is correct
6 Correct 3 ms 10588 KB Output is correct
7 Correct 3 ms 10588 KB Output is correct
8 Incorrect 3 ms 10584 KB Output isn't correct
9 Halted 0 ms 0 KB -