답안 #1041619

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041619 2024-08-02T06:21:21 Z 김은성(#11000) Brought Down the Grading Server? (CEOI23_balance) C++17
15 / 100
46 ms 29268 KB
#include <bits/stdc++.h>
using namespace std;
int n, s, t, *a[100009];
vector<pair<int, int> > graph[100009];
int ans[100009];
int deg[100009];	//out - in;
int cur[100009];
void findcycle(int v){
	for(int i = cur[v]; i<graph[v].size(); i++){
		if(i < cur[v])
			i = cur[v];
		if(i == graph[v].size())
			break;
		auto [idx, u] = graph[v][i];
		cur[v]++;
		if(ans[idx] != -1)
			continue;
		ans[idx] = v;
		deg[v]++;
		deg[u]--;
		findcycle(u);
	}
}
int main(){
	int i, j;
	scanf("%d %d %d", &n, &s, &t);
	memset(ans, -1, sizeof(ans));
	for(i=0; i<n; i++){
		a[i] = (int*)malloc(s * sizeof(int));
		for(j=0; j<s; j++){
			scanf("%d", &a[i][j]);
		}
		graph[a[i][0]].push_back(make_pair(i, a[i][1]));
		graph[a[i][1]].push_back(make_pair(i, a[i][0]));
	}
	for(i=1; i<=t; i++){
		findcycle(i);
	}
	for(i=1; i<=t; i++){
		assert(-1 <= deg[i] && deg[i] <= 1);
	}
	for(i=0; i<n; i++){
		printf("%d %d\n", ans[i], a[i][0] + a[i][1] - ans[i]);
	}
}

Compilation message

balance.cpp: In function 'void findcycle(int)':
balance.cpp:9:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i = cur[v]; i<graph[v].size(); i++){
      |                      ~^~~~~~~~~~~~~~~~
balance.cpp:12:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   if(i == graph[v].size())
      |      ~~^~~~~~~~~~~~~~~~~~
balance.cpp: In function 'int main()':
balance.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d %d %d", &n, &s, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
balance.cpp:31:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |    scanf("%d", &a[i][j]);
      |    ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Correct
2 Incorrect 1 ms 4444 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Correct
2 Runtime error 4 ms 8792 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 19292 KB Correct
2 Correct 36 ms 19012 KB Correct
3 Correct 36 ms 17492 KB Correct
4 Correct 23 ms 17336 KB Correct
5 Correct 33 ms 18888 KB Correct
6 Correct 46 ms 20816 KB Correct
7 Correct 35 ms 12372 KB Correct
8 Correct 33 ms 20316 KB Correct
9 Correct 38 ms 20816 KB Correct
10 Correct 31 ms 20932 KB Correct
11 Correct 33 ms 21076 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 19292 KB Correct
2 Correct 36 ms 19012 KB Correct
3 Correct 36 ms 17492 KB Correct
4 Correct 23 ms 17336 KB Correct
5 Correct 33 ms 18888 KB Correct
6 Correct 46 ms 20816 KB Correct
7 Correct 35 ms 12372 KB Correct
8 Correct 33 ms 20316 KB Correct
9 Correct 38 ms 20816 KB Correct
10 Correct 31 ms 20932 KB Correct
11 Correct 33 ms 21076 KB Correct
12 Correct 46 ms 20560 KB Correct
13 Correct 38 ms 20088 KB Correct
14 Correct 33 ms 17492 KB Correct
15 Correct 25 ms 17592 KB Correct
16 Correct 34 ms 20128 KB Correct
17 Correct 38 ms 20048 KB Correct
18 Correct 34 ms 13136 KB Correct
19 Correct 34 ms 21076 KB Correct
20 Correct 34 ms 20820 KB Correct
21 Correct 31 ms 20816 KB Correct
22 Correct 32 ms 20828 KB Correct
23 Runtime error 37 ms 29268 KB Execution killed with signal 6
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Correct
2 Runtime error 4 ms 8792 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4440 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4440 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4440 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 19292 KB Correct
2 Correct 36 ms 19012 KB Correct
3 Correct 36 ms 17492 KB Correct
4 Correct 23 ms 17336 KB Correct
5 Correct 33 ms 18888 KB Correct
6 Correct 46 ms 20816 KB Correct
7 Correct 35 ms 12372 KB Correct
8 Correct 33 ms 20316 KB Correct
9 Correct 38 ms 20816 KB Correct
10 Correct 31 ms 20932 KB Correct
11 Correct 33 ms 21076 KB Correct
12 Incorrect 1 ms 4440 KB Unexpected end of file - int32 expected
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 19292 KB Correct
2 Correct 36 ms 19012 KB Correct
3 Correct 36 ms 17492 KB Correct
4 Correct 23 ms 17336 KB Correct
5 Correct 33 ms 18888 KB Correct
6 Correct 46 ms 20816 KB Correct
7 Correct 35 ms 12372 KB Correct
8 Correct 33 ms 20316 KB Correct
9 Correct 38 ms 20816 KB Correct
10 Correct 31 ms 20932 KB Correct
11 Correct 33 ms 21076 KB Correct
12 Correct 46 ms 20560 KB Correct
13 Correct 38 ms 20088 KB Correct
14 Correct 33 ms 17492 KB Correct
15 Correct 25 ms 17592 KB Correct
16 Correct 34 ms 20128 KB Correct
17 Correct 38 ms 20048 KB Correct
18 Correct 34 ms 13136 KB Correct
19 Correct 34 ms 21076 KB Correct
20 Correct 34 ms 20820 KB Correct
21 Correct 31 ms 20816 KB Correct
22 Correct 32 ms 20828 KB Correct
23 Runtime error 37 ms 29268 KB Execution killed with signal 6
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Correct
2 Incorrect 1 ms 4444 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -