Submission #45869

#TimeUsernameProblemLanguageResultExecution timeMemory
45869TheDarkningPalembang Bridges (APIO15_bridge)C++17
Compilation error
0 ms0 KiB
/**
                  ▄█▀ ▀█▀ ▄▀▄ █▀ █▄█▄█ ▄▀▄ █▀ ▄█▀
                  <⇋⇋⇋⋛∰≓⊂(⌒,_ゝ⌒)⊃≓∰⋛⇋⇋⇋>

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

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 <string>
#include <set>

#define sz(s) s.size()
#define pb push_back
#define fr first
#define sc second
#define mk make_pair
#define int long long
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e6 + 5;
const int inf = 1e9 + 7;

int n, k, q, pos1, pos2, sumx, sumn, ans, sum, j;
char t1, t2;
double cnt;

inline void get()
{
   cin >> t1;
   cin >> pos1;
   cin >> t2;
   cin >> pos2;
}
vector < pair < int, int > > v;
main()
{
   cin >> k >> q;
   n = q;
   while( n-- )
   {
      get();
      if( t1 == t2 )
      {
         j += abs( pos1 - pos2 );
         continue;
      }

      cnt++;
      sumx += max( pos1, pos2 );
      sumn += min( pos1, pos2 );
      v.pb( mk( min( pos1, pos2 ), max( pos1, pos2 ) ) );
   }
   int pos = ceil( ( sumx + sumn ) * 1.0 / cnt / 2.0 );
   int pas = floor( ( sumx + sumn ) * 1.0 / cnt / 2.0 );

   for( auto x : v )
   {
      sum += abs( pos - x.fr ) + abs( pos - x.sc );
      ans += abs( pas - x.fr ) + abs( pas - x.sc );
   }
   cout << min( ans, sum ) + j + cnt;
}













Compilation message (stderr)

bridge.cpp:54:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
bridge.cpp: In function 'int main()':
bridge.cpp:72:14: error: 'ceil' was not declared in this scope
    int pos = ceil( ( sumx + sumn ) * 1.0 / cnt / 2.0 );
              ^~~~
bridge.cpp:73:14: error: 'floor' was not declared in this scope
    int pas = floor( ( sumx + sumn ) * 1.0 / cnt / 2.0 );
              ^~~~~
bridge.cpp:73:14: note: suggested alternative: 'float'
    int pas = floor( ( sumx + sumn ) * 1.0 / cnt / 2.0 );
              ^~~~~
              float