Submission #739168

# Submission time Handle Problem Language Result Execution time Memory
739168 2023-05-10T05:48:56 Z Cutebol Palembang Bridges (APIO15_bridge) C++17
8 / 100
2000 ms 2712 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define Ganyu ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
#define int long long
#define endl "\n"
#define ff first
#define ss second
  
const int N = 2e5 + 5 ;
const int inf = 1e17 ;
const int mod = 1e9 + 7 ;
 
int n , k , ans = inf ;
int b[N] , d[N] ;
char a[N] , c[N] ;
 
int ch ( int x ){
	int sum = 0 ;
	for ( int i = 0 ; i < n ; i ++ ) sum += ( a[i] != c[i] ) ? abs(b[i]-x)+abs(d[i]-x)+1 : abs(b[i]-d[i]) ;
	return sum ;
}
 
void solve(){
	
	cin >> k >> n ;
	set <int> t ;
	for ( int i = 0 ; i < n ; i ++ ) cin >> a[i] >> b[i] >> c[i] >> d[i] ;
	for ( int i = 0 ; i < n ; i ++ ) ans = min({ ch(b[i]) , ans , ch(d[i]) }) ;
	cout << ans ;
}
signed main(){
//	fopn("") ;
//	Ganyu ;
	int t = 1 ;
//	cin >> t ;
	while ( t -- ) solve() ;
	
}

Compilation message

bridge.cpp: In function 'void fopn(std::string)':
bridge.cpp:8:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bridge.cpp:8:72: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 5 ms 340 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
6 Correct 4 ms 320 KB Output is correct
7 Correct 4 ms 340 KB Output is correct
8 Correct 4 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 4 ms 320 KB Output is correct
6 Correct 4 ms 320 KB Output is correct
7 Correct 5 ms 340 KB Output is correct
8 Correct 4 ms 352 KB Output is correct
9 Correct 5 ms 324 KB Output is correct
10 Correct 4 ms 352 KB Output is correct
11 Correct 5 ms 316 KB Output is correct
12 Execution timed out 2075 ms 2712 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -