답안 #997480

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
997480 2024-06-12T11:19:30 Z ALTAKEXE 9월 (APIO24_september) C++17
0 / 100
7 ms 3164 KB
#include <bits/stdc++.h>
#include <vector>
using namespace std;
vector<vector<int>> adj(100005);
vector<bool> vis(100005, 0);
vector<int> p(100005, 0);
int c = -1;
void dfs(int u)
{
	if (vis[u])
		return;
	vis[u] = true;
	c = max(c, p[u]);
	for (auto i : adj[u])
		dfs(i);
}
int solve(int n, int m, vector<int> f, vector<vector<int>> s)
{
	for (int i = 1; i < n; i++)
		adj[f[i]].push_back(i);
	for (int j = 0; j < m; j++)
	{
		for (int i = 0; i < n - 1; i++)
			p[s[j][i]] = max(p[s[j][i]], i);
	}
	int ans = 0;
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (i > c && j == 0)
				ans++;
			dfs(s[j][i]);
		}
	}
	for (int i = 0; i < adj.size(); i++)
	{
		for (int j = 0; j < adj[i].size(); j++)
			adj[i][j] = 0;
	}
	c = -1;
	return ans;
}

Compilation message

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i = 0; i < adj.size(); i++)
      |                  ~~^~~~~~~~~~~~
september.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for (int j = 0; j < adj[i].size(); j++)
      |                   ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Incorrect 1 ms 3164 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Incorrect 1 ms 3164 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 3164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Incorrect 1 ms 3164 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 3164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Incorrect 1 ms 3164 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 3164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Incorrect 1 ms 3164 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 3164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Incorrect 1 ms 3164 KB Output isn't correct
3 Halted 0 ms 0 KB -