제출 #33621

#제출 시각아이디문제언어결과실행 시간메모리
33621sinhrivPalembang Bridges (APIO15_bridge)C++14
0 / 100
0 ms2020 KiB
#include <bits/stdc++.h> using namespace std; struct Point{ int x; int y; void read(){ char read[5]; scanf("%s%d", read, &y); x = (read[0] - 'A'); } }; struct Person{ Point u; Point v; bool check(){ u.read(); v.read(); return (u.x == v.x); } int calc(int val){ return abs(u.y - val) + abs(v.y - val); } }; vector < Person > a; long long One(){ int n = a.size(); vector < int > lst; for(int i = 0; i < n; ++i){ lst.push_back(a[i].u.y); lst.push_back(a[i].v.y); } sort(lst.begin(), lst.end()); long long ans = 0; for(int i = 0; i < n + n; ++i){ ans += abs(lst[i] - lst[n]); } return ans + n; } int main(){ if(fopen("1.inp", "r")){ freopen("1.inp", "r", stdin); } long long out = 0; int k, n; scanf("%d%d", &k, &n); for(int i = 1; i <= n; ++i){ Person x; if(x.check()){ out += x.calc(x.u.x); } else{ a.push_back(x); } } cout << One() + out; return 0; }

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

bridge.cpp: In function 'int main()':
bridge.cpp:55:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen("1.inp", "r", stdin);
                               ^
bridge.cpp:61:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &k, &n);
                       ^
bridge.cpp: In member function 'void Point::read()':
bridge.cpp:11:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s%d", read, &y);
                          ^
#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...