Submission #205754

#TimeUsernameProblemLanguageResultExecution timeMemory
205754ly20Political Development (BOI17_politicaldevelopment)C++17
16 / 100
183 ms146424 KiB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5123;
int grau[MAXN];
int tb[MAXN][MAXN];
int sq = sqrt(MAXN);
vector < int > ind;
vector <int> grafo[MAXN];
int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int resp = 1;
	for(int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a); grau[i] = a;
		if(a > 0) resp = 2;
		if(a > sq) ind.push_back(i);
		for(int j = 0; j < a; j++) {
			int b;
			scanf("%d", &b);
			tb[i][b] = 1;
			grafo[i].push_back(b);
		}
	}
	for(int i = 0; i < n; i++) {
		if(grau[i] <= sq) {
			for(int j = 0; j < grafo[i].size(); j++) {
				for(int k = j + 1; k < grafo[i].size(); k++) {
					if(tb[grafo[i][j]][grafo[i][k]] == 1) resp = 3;
				}
			}
		}
	}
	for(int i = 0; i < ind.size(); i++) {
		for(int j = i + 1; j < ind.size(); j++) {
			for(int k = j + 1; k < ind.size(); k++) {
				if(tb[ind[i]][ind[j]] == 1 && tb[ind[j]][ind[k]] == 1 && tb[ind[k]][ind[i]] == 1) resp = 3;
			}
		}
	}
	printf("%d\n", resp);
	return 0;
}

Compilation message (stderr)

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:27:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = 0; j < grafo[i].size(); j++) {
                   ~~^~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:28:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int k = j + 1; k < grafo[i].size(); k++) {
                        ~~^~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:34:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < ind.size(); i++) {
                 ~~^~~~~~~~~~~~
politicaldevelopment.cpp:35:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = i + 1; j < ind.size(); j++) {
                      ~~^~~~~~~~~~~~
politicaldevelopment.cpp:36:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k = j + 1; k < ind.size(); k++) {
                       ~~^~~~~~~~~~~~
politicaldevelopment.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a); grau[i] = a;
   ~~~~~^~~~~~~~~~
politicaldevelopment.cpp:20:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &b);
    ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...