Submission #48093

# Submission time Handle Problem Language Result Execution time Memory
48093 2018-05-10T04:50:27 Z TheDarkning Palembang Bridges (APIO15_bridge) C++17
8 / 100
2000 ms 2284 KB
/**
                  ▄█▀ ▀█▀ ▄▀▄ █▀ █▄█▄█ ▄▀▄ █▀ ▄█▀
                  <⇋⇋⇋⋛∰≓⊂(⌒,_ゝ⌒)⊃≓∰⋛⇋⇋⇋>

            ♔♕♖♗♘♙ ☜❷☞✪ ィℋ६ ≈ ᗫẵℜℵĬŊĞ ✪☜❷☞ ♚♛♜♝♞♟
            ♔♕♖♗♘♙                             ♚♛♜♝♞♟
                      ˙·٠•●♥ Ƹ̵̡Ӝ̵̨̄Ʒ ♥●•٠·˙
1 5
B 0 A 4
B 1 B 3
A 5 B 7
B 2 A 6
B 1 A 7

**/

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <time.h>
#include <map>
#include <deque>
#include <assert.h>
#include <queue>
#include <string>
#include <memory.h>
#include <set>
#include <math.h>

#define sz(s) s.size()
#define pb emplace_back
#define fr first
#define sc second
#define mk make_pair
#define int long long
#define all(s) s.begin(), s.end()
#define ok puts("ok");

using namespace std;

const int N = 2e5 + 5;
const int inf = 1e18 + 7;

int n, k, ans = inf, cnt, a[N], b[N];
char t1[N], t2[N];

main(){
    cin >> k >> n;
    for( int i = 1; i <= n; i++ ){
        cin >> t1[i] >> a[i] >> t2[i] >> b[i];
        if( t1[ i ] != t2[ i ] ){
            cnt ++;
        }
    }
    for( int i = 1; i <= n; i++ ){
        int sum = 0;
        for( int j = 1; j <= n; j++ ){
            if( t1[ j ] == t2[ j ] ){
                sum += abs( a[ j ] - b[ j ] );
                continue;
            }
            sum += abs( a[ j ] - a[ i ] ) + abs( b[ j ] - a[ i ] );
        }
        ans = min( ans, sum );
        sum = 0;
        for( int j = 1; j <= n; j++ ){
            if( t1[ j ] == t2[ j ] ){
                sum += abs( a[ j ] - b[ j ] );
                continue;
            }
            sum += abs( a[ j ] - b[ i ] ) + abs( b[ j ] - b[ i ] );
        }
        ans = min( ans, sum );
    }
    cout << ans + cnt;
}

Compilation message

bridge.cpp:49:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 7 ms 484 KB Output is correct
4 Correct 7 ms 484 KB Output is correct
5 Correct 7 ms 484 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 8 ms 532 KB Output is correct
8 Correct 7 ms 584 KB Output is correct
9 Correct 8 ms 584 KB Output is correct
10 Correct 7 ms 680 KB Output is correct
11 Correct 7 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 680 KB Output is correct
2 Correct 2 ms 680 KB Output is correct
3 Correct 7 ms 680 KB Output is correct
4 Correct 8 ms 680 KB Output is correct
5 Correct 13 ms 680 KB Output is correct
6 Correct 7 ms 680 KB Output is correct
7 Correct 8 ms 680 KB Output is correct
8 Correct 12 ms 680 KB Output is correct
9 Correct 13 ms 680 KB Output is correct
10 Correct 7 ms 680 KB Output is correct
11 Correct 7 ms 680 KB Output is correct
12 Execution timed out 2063 ms 2284 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2284 KB Output is correct
2 Correct 2 ms 2284 KB Output is correct
3 Incorrect 2 ms 2284 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2284 KB Output is correct
2 Correct 2 ms 2284 KB Output is correct
3 Incorrect 2 ms 2284 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2284 KB Output is correct
2 Correct 2 ms 2284 KB Output is correct
3 Incorrect 2 ms 2284 KB Output isn't correct
4 Halted 0 ms 0 KB -