답안 #764919

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764919 2023-06-24T06:32:48 Z vjudge1 Network (BOI15_net) C++17
0 / 100
0 ms 340 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e3;
bool used[N][N];
vector <int> g[N];
signed main(){
int n;
cin>>n;

for(int i=1;i<=n;i++){
	int x,y;
	cin>>x>>y;
	x--;
	y--;
	used[x][y]=1;
	used[y][x]=1;
g[x].push_back(y);
g[y].push_back(x);
}
vector <pair <int,int> > k;
for(int i=1;i<=n;i++){
	for(int j=1;j<=i;j++){
		if(!used[i-1][j-1] and g[i-1].size()==1){
			k.push_back(make_pair(i-1,j-1));
			used[i-1][j-1]=1;
			used[j-1][i-1]=1;
			g[i-1].push_back(j-1);
			g[j-1].push_back(i-1);
		}
	}
}
cout<<k.size()<<endl;
for(int i=0;i<k.size();i++){
	cout<<k[i].first+1<<" "<<k[i].second+1<<endl;
}

}

Compilation message

net.cpp: In function 'int main()':
net.cpp:34:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 | for(int i=0;i<k.size();i++){
      |             ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Invalid number of links.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Invalid number of links.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Invalid number of links.
3 Halted 0 ms 0 KB -