제출 #763855

#제출 시각아이디문제언어결과실행 시간메모리
763855qwerasdfzxclPalembang Bridges (APIO15_bridge)C++17
9 / 100
2059 ms312 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll solve2(vector<pair<int, int>> V){ if (V.empty()) return 0; ll ret = 4e18; vector<int> X; for (auto &[x, y]:V) {X.push_back(x); X.push_back(y);} for (int i=0;i<(int)X.size();i++){ for (int j=i+1;j<(int)X.size();j++){ ll val = 0; for (auto &[x, y]:V){ val += min(abs(x-X[i]) + abs(y-X[i]), abs(x-X[j]) + abs(y-X[j])); } ret = min(ret, val); } } return ret; } int main(){ int k, n; scanf("%d %d", &k, &n); ll ans = 0; vector<pair<int, int>> V; for (int i=1;i<=n;i++){ char cx, cy; int px, py; scanf(" %c %d %c %d", &cx, &px, &cy, &py); if (cx==cy) {ans += abs(px-py); continue;} if (cx=='B') swap(px, py); V.emplace_back(px, py); ans++; } if (k==2) ans += solve2(V); printf("%lld\n", ans); }

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

bridge.cpp: In function 'int main()':
bridge.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d %d", &k, &n);
      |  ~~~~~^~~~~~~~~~~~~~~~~
bridge.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf(" %c %d %c %d", &cx, &px, &cy, &py);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...