제출 #544888

#제출 시각아이디문제언어결과실행 시간메모리
544888mgl_diamondPalembang Bridges (APIO15_bridge)C++14
22 / 100
106 ms4740 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ii pair<int, int> #define fi first #define se second #define debug(x) cout << #x << ": " << x << "\n" #define all(x) x.begin(), x.end() template<class T> bool umax(T &a, T b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool umin(T &a, T b) { if (a>b) { a=b; return 1; } return 0; } void setIO(string name) { ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".inp").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const int mxN=100100; int k, n; char p[mxN], q[mxN]; int x[mxN], y[mxN]; ll ans; vector<int> v; void solve1() { for(int i=1; i<=n; ++i) if (p[i]==q[i]) ans+=abs(x[i]-y[i]); else v.push_back(x[i]), v.push_back(y[i]); sort(all(v)); int t=v.size(); for(int i=0; i<t; ++i) ans+=abs(v[t/2]-v[i]); cout << ans+v.size()/2 << '\n'; } int main() { cin >> k >> n; for(int i=1; i<=n; ++i) cin >> p[i] >> x[i] >> q[i] >> y[i]; if (k==1) solve1(); //else solve2(); }

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

bridge.cpp: In function 'void setIO(std::string)':
bridge.cpp:16:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  freopen((name+".inp").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bridge.cpp:17:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...