제출 #839988

#제출 시각아이디문제언어결과실행 시간메모리
839988math_rabbit_1028봉쇄 시간 (IOI23_closing)C++17
0 / 100
72 ms20940 KiB
#include "closing.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; int n, x, y, ch[202020], ans; ll k; vector<pll> adj[202020]; priority_queue<pll> pq; void add(int v, ll w) { ch[v] = 1; for (int i = 0; i < adj[v].size(); i++) { if (ch[adj[v][i].first] == 1) continue; pq.push({-w-adj[v][i].second, adj[v][i].first}); } } int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) { n = N, x = X, y = Y, k = K; ans = 0; for (int i = 0; i < n; i++) ch[i] = 0; for (int i = 0; i < n; i++) adj[i].clear(); if (!pq.empty()) pq.pop(); for (int i = 0; i < U.size(); i++) { adj[U[i]].push_back({V[i], W[i]}); adj[V[i]].push_back({U[i], W[i]}); } add(x, 0); add(y, 0); while (!pq.empty()) { int v = pq.top().second; ll w = -pq.top().first; pq.pop(); //cout << v << " " << w << "\n"; if (k - w >= 0) { ans++; k -= w; } else break; add(v, w); } return ans + 2; }

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

closing.cpp: In function 'void add(int, ll)':
closing.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i < adj[v].size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~
closing.cpp: In function 'int max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i = 0; i < U.size(); i++) {
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...