結果

問題 No.655 E869120 and Good Triangles
ユーザー Lepton_sLepton_s
提出日時 2018-02-23 23:43:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,815 bytes
コンパイル時間 1,401 ms
コンパイル使用メモリ 124,604 KB
実行使用メモリ 321,544 KB
最終ジャッジ日時 2023-07-31 08:47:49
合計ジャッジ時間 5,888 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,616 KB
testcase_01 AC 2 ms
5,632 KB
testcase_02 AC 2 ms
5,456 KB
testcase_03 AC 2 ms
5,676 KB
testcase_04 AC 2 ms
5,460 KB
testcase_05 AC 2 ms
5,668 KB
testcase_06 AC 2 ms
5,408 KB
testcase_07 AC 2 ms
5,512 KB
testcase_08 AC 2 ms
5,384 KB
testcase_09 AC 2 ms
5,408 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 AC 3 ms
5,420 KB
testcase_31 AC 3 ms
5,428 KB
testcase_32 AC 2 ms
5,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC optimize ("O3")
//#pragma GCC target ("tune=native")
//#pragma GCC target ("avx")
//#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);

#define N 4010
int d[N][N];
int n, m;
ll S;
int dx[] = {-1,-1,0,1,1,0}, dy[] = {0,-1,-1,0,1,1};
ll w1[N][N], w2[N][N];

ll f(ll x, ll y, ll z){
	ll r = w1[y][n-x+2]-w1[y+z][n-x+2-z];
	r -= w2[n+1][y+z]-w2[n+1][y]-w2[x+z][y+z]+w2[x+z][y];
	return r;
}

int main(){
	INIT;
	cin>>n>>m>>S;
	rep1(i, n) fill(d[i]+1, d[i]+i+1, INF);
	queue<P> q;
	rep(i, m){
		ll x, y;
		cin>>x>>y;
		d[x][y] = 0;
		q.push(P(x, y));
	}
	while(!q.empty()){
		P p = q.front(); q.pop();
		int x = p.fst, y = p.snd;
		rep(i, 6){
			int x2 = x+dx[i], y2= y+dy[i];
			if(x2<1||y2<1||x2>n||y2>x2||d[x2][y2]<INF) continue;
			d[x2][y2] = d[x][y]+1;
			q.push(P(x2, y2));
		}
	}
	rep1(i, n) rep1(j, n+1) w2[i+1][j+1] = w2[i][j+1]+w2[i+1][j]-w2[i][j]+d[i][j];
	rep1(i, n){
		w1[1][i+1] = w1[1][i];
		rep(j, i) w1[1][i+1] += d[n-j][j+1];
	}
	rep1(i, n) rep1(j, n-i+1) w1[i+1][j] = w1[i][j+1]-(w2[n+1][i+1]-w2[n-j+1][i+1]-w2[n+1][i]+w2[n-j+1][i]);
	ll res = 0;
	rep1(i, n) rep1(j, i){
		ll lb = 0, ub = n-i+2;
		while(ub-lb>1){
			ll md = (lb+ub)/2;
			(f(i, j, md)>=S?ub:lb)=md;
		}
		res += n-i+2-ub;
	}
	cout<<res<<endl;
	return 0;
}
0