Submission #999713

# Submission time Handle Problem Language Result Execution time Memory
999713 2024-06-16T05:42:54 Z AMel0n September (APIO24_september) C++17
0 / 100
0 ms 348 KB
#include "september.h"

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define rep(a) for(int i=0;i<a;++i)
#define ll long long
#define vi vector<int>
#define pi pair<int,int>


#define node S[i][j] 

int solve(int N, int M, std::vector<int> P, std::vector<std::vector<int>> S) {
	// vi CHILDREN(N);

	// for(int i=1; i<N; ++i) {
	// 	CHILDREN[P[i]]++;
	// }

	vector<vector<int>> um(M,vector<int>(N,-1));

    vector<pi> ranges(N, pi(-1,-1));
    rep(M) {
        for(int j=0; j<N - 1; ++j) {
            if (ranges[node].first == -1) {
                ranges[node].first = j;
            } else if (ranges[node].second == -1) {
                ranges[node].second = j;
            } else if (ranges[node].second < j) {
                ranges[node].second = j;
            } else if (um[i][P[node]] != -1) {
				ranges.push_back({um[i][P[node]],j});
			}
			um[i][node]=j;
        }
    }





    sort(ranges.begin(), ranges.end());
    int res = 0, l = 0, r = 0, i = 0;
    while (l < N - 1){
        while (i < ranges.size() && ranges[i].first <= r){
            r = max(r, ranges[i].second); i++;
        }
        res++;
        l = r + 1; r++;
    }
    

    return res;
}

Compilation message

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         while (i < ranges.size() && ranges[i].first <= r){
      |                ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -