제출 #68138

#제출 시각아이디문제언어결과실행 시간메모리
68138MrTEK무제 (POI11_kon)C++14
80 / 100
861 ms132096 KiB
#include <cstdio>
 
const int N = 5000;
 
int n;
 
int count[N];
int degree[N];
 
int main() {
	scanf("%d", &n);
	int edges = 0;
	for (int i = 1; i <= n; ++i) {
		int currentDegree;
		scanf("%d", &currentDegree);
		++count[currentDegree];
		edges += currentDegree;
		while (getchar() != '\n'); // pomijamy opis krawedzi
	}
	edges /= 2;
	int last = 0;
	for (int i = n - 1; i >= 0; --i)
		for (int j = 0; j < count[i]; ++j)
			degree[last++] = i;
	int m = 1;
	int result = 0;
	int sum = 0;
	for (int i = 0; i < n - 1; ++i) {
		sum += degree[i] - i;
		if (sum == edges) {
			if (degree[i + 1] == degree[i])
				result += count[degree[i]];
			else
				++result;
		}
	}
	printf("%d\n", result);
 
}

컴파일 시 표준 에러 (stderr) 메시지

kon.cpp: In function 'int main()':
kon.cpp:25:6: warning: unused variable 'm' [-Wunused-variable]
  int m = 1;
      ^
kon.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
kon.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &currentDegree);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...
#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...