Submission #895699

# Submission time Handle Problem Language Result Execution time Memory
895699 2023-12-30T14:45:56 Z beepbeepsheep Coin Collecting (JOI19_ho_t4) C++17
0 / 100
0 ms 360 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef tree<long long, null_type, less_equal<>,
        rb_tree_tag, tree_order_statistics_node_update>
        ordered_set;
#define ll long long
#define ii pair<ll,ll>

#ifndef DEBUG
#define cerr if (0) cerr
#define endl '\n'
#endif

const ll inf=1e15;
const ll maxn=1e5+5;
const ll mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll arr[maxn][3];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n,x,y,ans=0;
	cin>>n;
	for (int i=1;i<=2*n;i++){
		cin>>x>>y;
		if (x<=1 && y<=1) arr[1][1]++, ans+=abs(1-x)+abs(1-y);
		if (1<x && x<n && y<=1) arr[x][1]++, ans+=abs(1-y);
		if (x>=n && y<=1) arr[n][1]++, ans+=abs(n-x)+abs(1-y);
		if (x<=1 && y>=2) arr[1][2]++, ans+=abs(1-x)+abs(2-y);
		if (1<x && x<n && y>=2) arr[x][2]++, ans+=abs(2-y);
		if (x>=n && y>=2) arr[n][2]++, ans+=abs(n-x)+abs(2-y);
	}
	ll tot=0;
	for (int i=1;i<=2;i++){
		for (int j=1;j<=n;j++) cerr<<arr[j][i]<<' ';
		cerr<<endl;
	}
	for (int i=1;i<=n;i++){
		tot+=arr[i][1]+arr[i][2];
		ans+=abs(tot-2*i);
	}
	tot=0;
	for (int i=1;i<=n;i++){
		tot+=arr[i][1];
	}
	ans+=abs(n-tot);
	cout<<ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 360 KB Output isn't correct
2 Halted 0 ms 0 KB -