Submission #764919

#TimeUsernameProblemLanguageResultExecution timeMemory
764919vjudge1Network (BOI15_net)C++17
0 / 100
0 ms340 KiB
#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 (stderr)

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++){
      |             ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...