結果
| 問題 |
No.655 E869120 and Good Triangles
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-07-27 21:16:15 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,442 ms / 2,500 ms |
| コード長 | 2,614 bytes |
| コンパイル時間 | 3,393 ms |
| コンパイル使用メモリ | 277,580 KB |
| 実行使用メモリ | 412,388 KB |
| 最終ジャッジ日時 | 2025-07-27 21:16:56 |
| 合計ジャッジ時間 | 28,412 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include<bits/stdc++.h>
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
bool st;
using namespace std;
template<typename T>istream&operator>>(istream&I,vector<T>&v){for(auto&i:v)I>>i;return I;}
template<typename T>ostream&operator<<(ostream&O,vector<T> v){for(auto i:v)O<<i<<' ';return O;}
string TMP,STR;
stringstream CIN;
void read_all(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef debug
cerr<<"----------------------------------- START -----------------------------------\n";
while(getline(cin,TMP))STR+=TMP,STR+='\n';
CIN.str(STR);
cerr<<"\n--------------------------------- INPUT END ---------------------------------\n";
#endif
}
#ifdef debug
#define cin CIN
#endif
namespace AC{
int dx[]={0,1,0,-1,1,-1};
int dy[]={1,0,-1,0,-1,1};
int N,K,x,y,l,r,qx[10000000],qy[10000000],v[4010][4010],sx[4010][4010],sy[4010][4010];int X;
void solve(){
cin>>N>>K>>X;
for(int i=0;i<N;i++){
for(int j=0;j<N-i;j++){
v[i][j]=-1;
}
}
for(int i=0;i<K;i++){
cin>>x>>y;
x=x-y,y--;
if(v[x][y]==-1)v[x][y]=0,qx[r]=x,qy[r++]=y;
}
while(l!=r){
x=qx[l],y=qy[l++];
for(int i=0;i<6;i++){
int tx=x+dx[i],ty=y+dy[i];
if(0<=tx&&tx<N&&0<=ty&&ty<N&&0<=tx+ty&&tx+ty<N&&v[tx][ty]==-1){
v[tx][ty]=v[x][y]+1;
qx[r]=tx,qy[r++]=ty;
}
}
}
for(int i=0;i<N;i++){
for(int j=0;j<N-i;j++){
sx[i][j+1]=sx[i][j]+v[i][j];
sy[i][j+1]=sy[i][j]+v[j][i];
}
}
int ret=0;
for(int i=0;i<N;i++){
int cx=i+1;int cs=0;
for(int j=0;j<=i;j++){
while(cx!=0){
int delta=sy[cx-1][i-cx+2]-sy[cx-1][j];
if(cs+delta>=X)break;
cs+=delta;
cx--;
}
ret+=cx;
cs-=sx[j][i-j+1]-sx[j][cx];
}
}
cout<<ret;
}
}
bool ed;
signed main(){
chrono::steady_clock::time_point St=chrono::steady_clock::now();
read_all();
chrono::steady_clock::time_point ST=chrono::steady_clock::now();
int t=1;
//cin>>t;
while(t--)AC::solve();
chrono::steady_clock::time_point ED=chrono::steady_clock::now();
cerr<<setprecision(3)<<fixed<<"\n\n------------------------------------ END ------------------------------------\n"<<"Total Time : "<<left<<setw(10)<<chrono::duration_cast<chrono::milliseconds>(ED-St).count()<<" \tms\n"<<"Real Time : "<<left<<setw(10)<<chrono::duration_cast<chrono::milliseconds>(ED-ST).count()<<" \tms\n"<<" : "<<left<<setw(10)<<chrono::duration_cast<chrono::microseconds>(ED-ST).count()<<" \t?s\n\n"<<"Total Memory : "<<left<<setw(10)<<(&ed-&st)/1048576.0<<" \tMB\n"<<" "<<left<<setw(10)<<(&ed-&st)/1024.0<<" \tKB\n"<<" "<<left<<setw(10)<<(&ed-&st)<<" \tByte\n";
}
vjudge1