답안 #288431

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
288431 2020-09-01T13:35:48 Z davi_bart Simurgh (IOI17_simurgh) C++14
0 / 100
248 ms 4596 KB
//#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define ld long double
/*
4 6
0 1
0 2
0 3
1 2
1 3
2 3
0 1 5
*/
int count_common_roads(const vector<int>& r);
int N;
vector<pair<int,int> > p[600];
vector<int> grafo(int pos){
  vector<int> v;
  vector<bool> vis(N,0);
  queue<pair<int,int> >q;
  if(pos==0)q.push({1,-1});
  else q.push({0,-1});
  while(!q.empty()){
    auto &[pp,idx]=q.front();
    q.pop();
    if(vis[pp])continue;
    vis[pp]=1;
    if(idx!=-1)v.push_back(idx);
    for(auto x:p[pp]){
      if(x.first!=pos)q.push({x.first,x.second});
    }
  }
  return v;
}
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v){
  N=n;
  for(int i=0;i<u.size();i++){
    p[u[i]].push_back({v[i],i});
    p[v[i]].push_back({u[i],i});
  }
  vector<int> ans;
	for(int i=0;i<N;i++){
    auto x=grafo(i);
    if(x.size()!=N-2)continue;
    int ma=0;
    vector<int> k;
    for(auto y:p[i]){
      x.push_back(y.second);
      k.push_back(count_common_roads(x));
      x.pop_back();
      ma=max(ma,k.back());
    }
    for(int j=0;j<p[i].size();j++){
      if(k[j]==ma)ans.push_back(p[i][j].second);
    }
	}
	sort(ans.begin(),ans.end());
	ans.resize(unique(ans.begin(),ans.end())-ans.begin());
	return ans;
}

Compilation message

simurgh.cpp: In function 'std::vector<int> grafo(int)':
simurgh.cpp:28:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |     auto &[pp,idx]=q.front();
      |           ^
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:41:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   for(int i=0;i<u.size();i++){
      |               ~^~~~~~~~~
simurgh.cpp:48:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |     if(x.size()!=N-2)continue;
      |        ~~~~~~~~^~~~~
simurgh.cpp:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int j=0;j<p[i].size();j++){
      |                 ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB correct
2 Correct 0 ms 384 KB correct
3 Correct 0 ms 384 KB correct
4 Correct 0 ms 256 KB correct
5 Correct 0 ms 384 KB correct
6 Correct 0 ms 384 KB correct
7 Correct 0 ms 384 KB correct
8 Correct 1 ms 384 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 0 ms 384 KB correct
11 Incorrect 0 ms 384 KB WA in grader: NO
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB correct
2 Correct 0 ms 384 KB correct
3 Correct 0 ms 384 KB correct
4 Correct 0 ms 256 KB correct
5 Correct 0 ms 384 KB correct
6 Correct 0 ms 384 KB correct
7 Correct 0 ms 384 KB correct
8 Correct 1 ms 384 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 0 ms 384 KB correct
11 Incorrect 0 ms 384 KB WA in grader: NO
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB correct
2 Correct 0 ms 384 KB correct
3 Correct 0 ms 384 KB correct
4 Correct 0 ms 256 KB correct
5 Correct 0 ms 384 KB correct
6 Correct 0 ms 384 KB correct
7 Correct 0 ms 384 KB correct
8 Correct 1 ms 384 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 0 ms 384 KB correct
11 Incorrect 0 ms 384 KB WA in grader: NO
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB correct
2 Correct 1 ms 384 KB correct
3 Incorrect 248 ms 4596 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB correct
2 Correct 0 ms 384 KB correct
3 Correct 0 ms 384 KB correct
4 Correct 0 ms 256 KB correct
5 Correct 0 ms 384 KB correct
6 Correct 0 ms 384 KB correct
7 Correct 0 ms 384 KB correct
8 Correct 1 ms 384 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 0 ms 384 KB correct
11 Incorrect 0 ms 384 KB WA in grader: NO
12 Halted 0 ms 0 KB -