Submission #1100105

#TimeUsernameProblemLanguageResultExecution timeMemory
1100105Omar_ElgedawyPalembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms352 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define F first #define S second #define el '\n' #define cout(x) for(auto v:x)cout<<v<<' ';cout<<el #define coutp(x) for(auto v:x)cout<<v.F<<' '<<v.S<<el #define cin(x) for(auto &v:x)cin>>v; #define pb(x) push_back(x) #define all(x) x.begin(),x.end() const int N = 2e6 + 5, M = 1e2 + 5, Mod = 1e9 + 7; int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1}; int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1}; void solve(int T) { int k, n; cin >> k >> n; vector<pair<int,int>> v; int sum = 0; for (int i = 0; i < n; i++) { char zn1, zn2; int loc1, loc2; cin >> zn1 >> loc1 >> zn2 >> loc2; if (zn1 == zn2) sum += abs(loc1 - loc2); else { v.emplace_back(loc1, loc2); } } // coutp(v); int mn = 1e18; for (int i = 0; i < v.size(); i++) { int cur = 0, cur2 = 0; int loc = v[i].F; for (int j = 0; j < v.size(); j++) { cur += abs(v[j].F - loc) + abs(v[j].S - loc) + 1; } loc = v[i].S; for (int j = 0; j < v.size(); j++) { cur2 += abs(v[j].F - loc) + abs(v[j].S - loc) + 1; } mn = min({mn, cur, cur2}); // cout<<cur<<' '<<cur2<<el; } cout << mn + sum << el; } int32_t main() { // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); int tc = 1; // cin >> tc; for (int i = 1; i <= tc; i++)solve(i); return 0; }

Compilation message (stderr)

bridge.cpp: In function 'void solve(long long int)':
bridge.cpp:39:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
bridge.cpp:43:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int j = 0; j < v.size(); j++)
      |                         ~~^~~~~~~~~~
bridge.cpp:48:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (int j = 0; j < v.size(); j++)
      |                         ~~^~~~~~~~~~
#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...