제출 #996266

#제출 시각아이디문제언어결과실행 시간메모리
996266chandu33Paths (BOI18_paths)C++17
23 / 100
3088 ms9436 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> adj[100001]; vector<int> colors(100001, -1); ll ans = 0; void dfs(int node, vector<bool> &visited, set<int> &pathColors) { visited[node] = true; pathColors.insert(colors[node]); for (auto &child : adj[node]) { if (!visited[child] && pathColors.find(colors[child]) == pathColors.end()) { ans++; dfs(child, visited, pathColors); } } visited[node] = false; pathColors.erase(colors[node]); } int main() { int N, M, K; scanf("%d %d %d", &N, &M, &K); for (int i = 0; i < N; i++) { scanf("%d", &colors[i]); } for (int i = 0; i < M; i++) { int U, V; scanf("%d %d", &U, &V); --U; --V; adj[U].push_back(V); adj[V].push_back(U); } vector<bool> visited(N, false); set<int> pathColors; for (int i = 0; i < N; i++) { if (!visited[i]) { dfs(i, visited, pathColors); } } printf("%lld\n", ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

paths.cpp: In function 'int main()':
paths.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   scanf("%d %d %d", &N, &M, &K);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
paths.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%d", &colors[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
paths.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%d %d", &U, &V);
      |     ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...