답안 #321954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321954 2020-11-13T14:43:26 Z katearima 기지국 (IOI20_stations) C++14
5 / 100
1140 ms 56280 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N=1005;
vector<vector<int>> a(N);
vector<int> ans(N);
int i,n,k,m,x,j,t;
void DFS(vector<vector<int>> a, int x,int y,int d){
	if(d%2==0) {ans[y]=t; t++;}
	for(int i=0; i<a[y].size(); i++){
		if(a[y][i]==x) continue;
		DFS(a,y,a[y][i],d+1);
	}
	if(d%2!=0) {ans[y]=t; t++;}
	
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> label(n);
	for(i=0; i<n; i++){
		a[i].clear();
		ans[i]=0;
	}
	for(i=0; i<n-1; i++){
		a[u[i]].push_back(v[i]);
		a[v[i]].push_back(u[i]);
	}
    t=0;
	DFS(a,-1,0,0);
	/*for(i=0; i<n; i++){
		cout<<ans[i]<<endl;
	}*/
	for(i=0; i<n; i++) label[i]=ans[i];
	//ans.clear(); a.clear();
	return label;
}

int find_next_station(int s, int t, vector<int> c) {
	bool parent=true;
	int ans;
	
	if(s<c[0]){
		c.insert(c.begin(),s);
		for(int i=1; i<c.size()-1; i++){
			if(t<=c[i] && t>=c[i-1]+1) return c[i];
		}
		return c[c.size()-1];
	}
	else{
		c.push_back(s);
		for(int i=1; i<c.size()-1; i++){
			if(t>=c[i] && t<=c[i+1]-1) return c[i];
			return c[0];
		}
	}
	//cout<<"ans"<<ans<<endl;
	//if(ans==s) 
	return c[0];
}

Compilation message

stations.cpp: In function 'void DFS(std::vector<std::vector<int> >, int, int, int)':
stations.cpp:11:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0; i<a[y].size(); i++){
      |               ~^~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for(int i=1; i<c.size()-1; i++){
      |                ~^~~~~~~~~~~
stations.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   for(int i=1; i<c.size()-1; i++){
      |                ~^~~~~~~~~~~
stations.cpp:39:7: warning: unused variable 'parent' [-Wunused-variable]
   39 |  bool parent=true;
      |       ^~~~~~
stations.cpp:40:6: warning: unused variable 'ans' [-Wunused-variable]
   40 |  int ans;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 871 ms 56280 KB Output is correct
2 Correct 1041 ms 55520 KB Output is correct
3 Correct 866 ms 736 KB Output is correct
4 Correct 601 ms 1244 KB Output is correct
5 Correct 602 ms 972 KB Output is correct
6 Correct 1022 ms 49936 KB Output is correct
7 Correct 495 ms 42080 KB Output is correct
8 Correct 3 ms 1132 KB Output is correct
9 Correct 4 ms 992 KB Output is correct
10 Correct 2 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1073 ms 1476 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 867 ms 56068 KB Output is correct
2 Correct 1077 ms 54224 KB Output is correct
3 Correct 992 ms 880 KB Output is correct
4 Correct 724 ms 876 KB Output is correct
5 Correct 617 ms 864 KB Output is correct
6 Correct 1104 ms 53856 KB Output is correct
7 Correct 636 ms 43100 KB Output is correct
8 Correct 3 ms 1088 KB Output is correct
9 Correct 4 ms 992 KB Output is correct
10 Correct 2 ms 1116 KB Output is correct
11 Incorrect 610 ms 864 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 989 ms 880 KB Output is correct
2 Correct 699 ms 1236 KB Output is correct
3 Correct 596 ms 1096 KB Output is correct
4 Correct 3 ms 1096 KB Output is correct
5 Correct 5 ms 908 KB Output is correct
6 Correct 2 ms 864 KB Output is correct
7 Incorrect 694 ms 992 KB Wrong query response.
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 909 ms 55988 KB Output is correct
2 Correct 1140 ms 49504 KB Output is correct
3 Correct 952 ms 736 KB Output is correct
4 Correct 650 ms 992 KB Output is correct
5 Correct 587 ms 1088 KB Output is correct
6 Correct 1066 ms 56172 KB Output is correct
7 Correct 511 ms 31584 KB Output is correct
8 Correct 3 ms 1088 KB Output is correct
9 Correct 4 ms 864 KB Output is correct
10 Correct 2 ms 864 KB Output is correct
11 Incorrect 970 ms 1632 KB Wrong query response.
12 Halted 0 ms 0 KB -