제출 #498465

#제출 시각아이디문제언어결과실행 시간메모리
498465YuisuyunoPalembang Bridges (APIO15_bridge)C++14
22 / 100
42 ms7288 KiB
//Nguyen Huu Hoang Minh #include <bits/stdc++.h> #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define reset(x) memset(x, 0,sizeof(x)) #define pb push_back #define mp make_pair #define fi first #define se second #define N 100005 #define remain(x) if (x > MOD) x -= MOD #define ii pair<int, int> #define iiii pair< ii , ii > #define viiii vector< iiii > #define vi vector<int> #define vii vector< ii > #define bit(x, i) (((x) >> (i)) & 1) #define Task "test" #define int long long using namespace std; typedef long double ld; const int inf = 1e10; const int minf = -1e10; int n, k; struct ppl{ int s, t; bool operator < (const ppl &a) const{ return s+t < a.s + a.t; } }; vector<ppl> Q; int ans = 0; void readfile() { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); if (fopen(Task".inp","r")) { freopen(Task".inp","r",stdin); //freopen(Task".out","w",stdout); } cin >> k >> n; for(int i=1; i<=n; i++){ char a, b; int x, y; cin >> a >> x >> b >> y; if (a==b) ans += abs(x-y); else{ Q.pb({x,y}); } } } void solve1(){ vector<int> val; for(int i=0; i<Q.size(); i++) val.pb(Q[i].s), val.pb(Q[i].t); sort(all(val)); //val.erase(unique(all(val)),val.end()); int x = val[(val.size()+1)/2 - 1]; for(int i=0; i<Q.size(); i++){ ans += abs(Q[i].s - x) + abs(Q[i].t - x) + 1; } //cout << x << '\n'; cout << ans; } void proc() { if (k==1){ solve1(); return; } } signed main() { readfile(); proc(); return 0; }

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

bridge.cpp: In function 'void solve1()':
bridge.cpp:60:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<ppl>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for(int i=0; i<Q.size(); i++) val.pb(Q[i].s), val.pb(Q[i].t);
      |                  ~^~~~~~~~~
bridge.cpp:64:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<ppl>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int i=0; i<Q.size(); i++){
      |                  ~^~~~~~~~~
bridge.cpp: In function 'void readfile()':
bridge.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         freopen(Task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...