結果
問題 | No.655 E869120 and Good Triangles |
ユーザー | WA_TLE |
提出日時 | 2018-02-01 19:46:28 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 318 ms / 2,500 ms |
コード長 | 3,387 bytes |
コンパイル時間 | 1,612 ms |
コンパイル使用メモリ | 133,608 KB |
実行使用メモリ | 409,000 KB |
最終ジャッジ日時 | 2024-04-18 09:44:20 |
合計ジャッジ時間 | 7,984 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 3 ms
6,944 KB |
testcase_04 | AC | 3 ms
6,944 KB |
testcase_05 | AC | 3 ms
6,944 KB |
testcase_06 | AC | 3 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 3 ms
6,948 KB |
testcase_10 | AC | 318 ms
399,536 KB |
testcase_11 | AC | 274 ms
399,712 KB |
testcase_12 | AC | 278 ms
400,244 KB |
testcase_13 | AC | 273 ms
402,752 KB |
testcase_14 | AC | 287 ms
402,004 KB |
testcase_15 | AC | 289 ms
404,036 KB |
testcase_16 | AC | 315 ms
402,904 KB |
testcase_17 | AC | 300 ms
398,960 KB |
testcase_18 | AC | 293 ms
399,396 KB |
testcase_19 | AC | 290 ms
397,224 KB |
testcase_20 | AC | 307 ms
399,152 KB |
testcase_21 | AC | 304 ms
407,340 KB |
testcase_22 | AC | 270 ms
402,628 KB |
testcase_23 | AC | 266 ms
403,012 KB |
testcase_24 | AC | 228 ms
402,352 KB |
testcase_25 | AC | 224 ms
406,016 KB |
testcase_26 | AC | 226 ms
397,864 KB |
testcase_27 | AC | 271 ms
401,024 KB |
testcase_28 | AC | 224 ms
409,000 KB |
testcase_29 | AC | 248 ms
401,592 KB |
testcase_30 | AC | 3 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,944 KB |
testcase_32 | AC | 2 ms
6,944 KB |
ソースコード
#include<deque> #include<queue> #include<vector> #include<algorithm> #include<iostream> #include<set> #include<cmath> #include<tuple> #include<string> #include<chrono> #include<functional> #include<iterator> #include<random> #include<unordered_set> #include<unordered_map> #include<array> #include<map> #include<bitset> #include<iomanip> #include<list> #include <numeric> using namespace std; typedef unsigned long long int ulint; typedef long long int llint; typedef long double lldo; #define mp make_pair #define mt make_tuple #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define fir first #define sec second #define res resize #define ins insert #define era erase #define RE return 0 //ios::sync_with_stdio(false); //std::cin.tie(0); //<< setprecision(20) const int mod=(int)1e9+7; const llint big=(llint)44e15; const long double pai=3.141592653589793238462643383279502884197; const long double ena=2.71828182845904523536; const long double eps=1e-7; template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}} template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}} template <class T> void soun(T& ar) {sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());} llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}} llint lcm(llint a,llint b){return a/gcd(a,b) *b;} template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);} template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);} template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();} template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();} template<class T> void SO(T& ve){sort(ve.begin(),ve.end());} template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());} int main(void){ //ういーんビートビートひるどww llint n,K,p,i,j;cin>>n>>K>>p; static int a[4002][4002]; for(i=1;i<=n;i++){ for(j=1;j<=i;j++){a[i][j]=mod;} } for(i=0;i<K;i++){int x,y;cin>>x>>y;a[x][y]=0;} for(i=1;i<=n;i++){ for(j=1;j<i;j++){mineq(a[i][j+1],a[i][j]+1);} for(j=i;j>1;j--){mineq(a[i][j-1],a[i][j]+1);} } for(i=1;i<n;i++){ for(j=1;j<=i;j++){mineq(a[i+1][j+1],a[i][j]+1);} for(j=1;j<=i;j++){mineq(a[i+1][j],a[i][j]+1);} } for(i=n;i>1;i--){ for(j=1;j<i;j++){mineq(a[i-1][j],a[i][j]+1);} for(j=2;j<=i;j++){mineq(a[i-1][j-1],a[i][j]+1);} } //aの値が求まった static llint wata[4002][4002]={0};//縦累積和 static llint wana[4002][4002]={0};//ななめ累積和 static llint wayo[4002][4002]={0};//ななめ累積和 for(i=1;i<=n;i++){for(j=1;j<=i;j++){ wata[i][j]=a[i][j]+wata[i-1][j]; wana[i][j]=a[i][j]+wana[i-1][j-1]; wayo[i][j]=a[i][j]+wayo[i][j-1]; }} llint ans=0; array<llint,4002> gen={0};//現在の三角の数字 array<int,4002> made={0};//どこまで for(i=1;i<=n;i++){ array<llint,4002>ngen; array<int,4002>nmade; for(j=1;j<=i;j++){ int dco=max(made[j-1],made[j]); llint now=0; if(dco==made[j-1]){now=gen[j-1]-wata[dco][j-1]+wata[i-1][j-1]-a[i-1][j-1];} else{now=gen[j]-wana[dco][dco-i+j+1]+wana[i-1][j]-a[i-1][j];} //cerr<<wata[i][j]<<" "; while(dco<=n&&now<p){ dco++; now+=wayo[dco][dco-i+j]-wayo[dco][j-1]; } ans+=1+n-dco; ngen[j]=now; nmade[j]=dco; } //cerr<<endl; swap(gen,ngen); swap(made,nmade); } cout<<ans<<endl; }