답안 #563633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563633 2022-05-17T19:17:30 Z Abrar_Al_Samit Paths (BOI18_paths) C++17
23 / 100
3000 ms 13788 KB
#include<bits/stdc++.h>
using namespace std;

const int MX = 3e5 + 5;
vector<int>g[MX];
int n, m, k;
int tag[MX];

long long ans = 0;
int cur[6];

void solve(int v, bool first = 0) {
  if(cur[tag[v]]) return;
  cur[tag[v]] = 1;
  if(!first) ++ans;

  //cerr<<"v = "<<v<<endl;
  for(auto u : g[v]) {
    //cerr<<u<<endl;
    solve(u);
  }

  cur[tag[v]] = 0;
}
void PlayGround() {
  cin>>n>>m>>k;
  for(int i=1; i<=n; ++i) {
    cin>>tag[i];
  }
  for(int i=0; i<m; ++i) {
    int u, v;
    cin>>u>>v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  //solve(1);
  //solve(2, 1);
  for(int i=1; i<=n; ++i) {
    solve(i, 1);
    //cout<<ans<<endl;
  }
  cout<<ans<<'\n';

}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  PlayGround();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7364 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 5 ms 7252 KB Output is correct
4 Correct 4 ms 7376 KB Output is correct
5 Correct 4 ms 7368 KB Output is correct
6 Correct 4 ms 7380 KB Output is correct
7 Correct 4 ms 7252 KB Output is correct
8 Correct 4 ms 7368 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3062 ms 13788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7364 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 5 ms 7252 KB Output is correct
4 Correct 4 ms 7376 KB Output is correct
5 Correct 4 ms 7368 KB Output is correct
6 Correct 4 ms 7380 KB Output is correct
7 Correct 4 ms 7252 KB Output is correct
8 Correct 4 ms 7368 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Execution timed out 3062 ms 13788 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Execution timed out 3064 ms 9192 KB Time limit exceeded
3 Halted 0 ms 0 KB -