답안 #405600

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
405600 2021-05-16T15:00:16 Z victoriad Regions (IOI09_regions) C++14
29 / 100
8000 ms 131076 KB
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
 vector<int>region;
 void dfs(int nodo,vector<vector<int> >&g,vector<bool>&vi,vector<int>&b){
     vi[nodo]=true;
     b[region[nodo]]++;
     for(int c:g[nodo]){
         if(!vi[c]){
             dfs(c,g,vi,b);
         }
     }
 }
 
int main(){
  int N,R,Q;
  cin>>N>>R>>Q;
  vector<vector<int> >g(N);
  g.clear();
  region.resize(N);
  int a,b;
  cin>>a;
  a--;
  region[0]=a;
  for(int i=1;i<N;i++){
    cin>>a>>b;
    a--;
    b--;
    region[i]=b;
    g[a].push_back(i);
  }
  vector<vector<int> >bus(R);
  vector<int>vacio(R,0);
  for(int i=0;i<R;i++)bus[i]=vacio;

  for(int i=0;i<N;i++){
      int j=region[i];
      vector<bool>vi(N,false);
      dfs(i,g,vi,bus[j]);
  }
  for(int i=0;i<Q;i++){
      cin>>a>>b;
        a--;
        b--;
      cout<<bus[a][b]<<"\n";
  }
   
    
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 4 ms 200 KB Output is correct
4 Correct 6 ms 200 KB Output is correct
5 Correct 11 ms 328 KB Output is correct
6 Correct 29 ms 584 KB Output is correct
7 Correct 40 ms 456 KB Output is correct
8 Correct 38 ms 456 KB Output is correct
9 Correct 252 ms 1344 KB Output is correct
10 Correct 128 ms 1540 KB Output is correct
11 Correct 246 ms 1460 KB Output is correct
12 Correct 869 ms 2536 KB Output is correct
13 Correct 207 ms 1724 KB Output is correct
14 Correct 291 ms 2088 KB Output is correct
15 Execution timed out 8084 ms 5320 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 8079 ms 5624 KB Time limit exceeded
2 Correct 4096 ms 4364 KB Output is correct
3 Execution timed out 8042 ms 7988 KB Time limit exceeded
4 Correct 1168 ms 64732 KB Output is correct
5 Correct 6991 ms 102224 KB Output is correct
6 Runtime error 101 ms 131076 KB Execution killed with signal 9
7 Runtime error 116 ms 131076 KB Execution killed with signal 9
8 Runtime error 125 ms 131076 KB Execution killed with signal 9
9 Runtime error 173 ms 131076 KB Execution killed with signal 9
10 Runtime error 180 ms 131076 KB Execution killed with signal 9
11 Runtime error 199 ms 131076 KB Execution killed with signal 9
12 Runtime error 203 ms 131076 KB Execution killed with signal 9
13 Runtime error 184 ms 131076 KB Execution killed with signal 9
14 Runtime error 199 ms 131076 KB Execution killed with signal 9
15 Runtime error 195 ms 131076 KB Execution killed with signal 9
16 Runtime error 201 ms 131076 KB Execution killed with signal 9
17 Runtime error 189 ms 131076 KB Execution killed with signal 9