제출 #365934

#제출 시각아이디문제언어결과실행 시간메모리
365934BartolMPalembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms492 KiB
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;

const int INF=0x3f3f3f3f;

int k, n;
ll sol=0;
vector <int> v;

void solve() {
//    assert(k==1);
    int len=v.size();
    int ind=v[len/2];
    for (int i=0; i<len; ++i) sol+=abs(v[i]-v[ind]);
    printf("%lld\n", sol+len/2);
}

void load() {
    scanf("%d %d", &k, &n);
    for (int i=0; i<n; ++i) {
        char ca, cb; int a, b;
        scanf(" %c %d %c %d", &ca, &a, &cb, &b);
        if (ca==cb) sol+=abs(a-b);
        else v.pb(a), v.pb(b);
    }
}

int main() {
    load();
    solve();
    return 0;
}

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

bridge.cpp: In function 'void load()':
bridge.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |     scanf("%d %d", &k, &n);
      |     ~~~~~^~~~~~~~~~~~~~~~~
bridge.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |         scanf(" %c %d %c %d", &ca, &a, &cb, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...