답안 #26593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26593 2017-07-03T12:18:33 Z model_code Conspiracy (POI11_kon) C++11
100 / 100
1213 ms 1156 KB
/*************************************************************************}
{*                                                                       *}
{*   Zadanie: Konspiracja (KON)                                          *}
{*   Plik:    kon.cpp                                                    *}
{*   Autor:   Jakub Pachocki                                             *}
{*   Opis:    Rozwiązanie wzorcowe                                       *}
{*            Złożoność: O(n + m)                                        *}
{*            Kodowanie znaków: UTF-8                                    *}
{*                                                                       *}
{*************************************************************************/

#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);

}

Compilation message

kon.cpp: In function 'int main()':
kon.cpp:36:6: warning: unused variable 'm' [-Wunused-variable]
  int m = 1;
      ^
kon.cpp:22:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
kon.cpp:26:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &currentDegree);
                              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1156 KB Output is correct
2 Correct 0 ms 1156 KB Output is correct
3 Correct 0 ms 1156 KB Output is correct
4 Correct 0 ms 1156 KB Output is correct
5 Correct 0 ms 1156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1156 KB Output is correct
2 Correct 0 ms 1156 KB Output is correct
3 Correct 0 ms 1156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1156 KB Output is correct
2 Correct 0 ms 1156 KB Output is correct
3 Correct 0 ms 1156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1156 KB Output is correct
2 Correct 0 ms 1156 KB Output is correct
3 Correct 0 ms 1156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1156 KB Output is correct
2 Correct 0 ms 1156 KB Output is correct
3 Correct 0 ms 1156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1156 KB Output is correct
2 Correct 36 ms 1156 KB Output is correct
3 Correct 146 ms 1156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1156 KB Output is correct
2 Correct 36 ms 1156 KB Output is correct
3 Correct 189 ms 1156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1156 KB Output is correct
2 Correct 83 ms 1156 KB Output is correct
3 Correct 253 ms 1156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 1156 KB Output is correct
2 Correct 206 ms 1156 KB Output is correct
3 Correct 759 ms 1156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 489 ms 1156 KB Output is correct
2 Correct 299 ms 1156 KB Output is correct
3 Correct 929 ms 1156 KB Output is correct
4 Correct 1213 ms 1156 KB Output is correct
5 Correct 0 ms 1156 KB Output is correct