提出 #373740


ソースコード 拡げる

#include<vector>
#include<map>
#include<climits>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<bitset>
#include<cstring>
#include<list>
#include<ctime>
#include<iterator>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)


bool dp[2][1005][1005];

inline int abs(int val){
    return val>=0?val:val*-1;
}
int main(){
    int M;scanf("%d",&M);
    int x[1003],y[1003],s[1003],t[1003];
    rep(i,M){
        scanf("%d%d",x+i,y+i);
        s[i]=0;t[i]=0;
    }
    int N;scanf("%d",&N);
    rep(i,N)scanf("%d%d%d%d",x+i+M,y+i+M,s+i+M,t+i+M);



    if(M==1){
        bool flag=true;
        rep(i,N+M-1)if(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])>s[i+1]-t[i])flag=false;

        if(flag)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        return 0;
    }

    if(M==2){
        bool dp[2][1005]={{0}};
        dp[M&1][0]=true;

        rrep(i,M,M+N){
            rep(j,i){
                if(dp[i&1][j]==false)continue;
                if(abs(x[i]-x[j])+abs(y[i]-y[j])<=s[i]-t[j])dp[(i+1)&1][i-1]=true;
                if(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])<=s[i]-t[i-1])dp[(i+1)&1][j]=true;
                dp[i&1][j]=false;
            }
        }
        rep(i,N+M-1)if(dp[(N+M)&1][i]){
            cout<<"YES"<<endl;
            return 0;
        }
        cout<<"NO"<<endl;
        return 0;
    }


    dp[M&1][0][1]=true;

    rrep(i,M,N+M){
        rep(a,i-1)rrep(b,a+1,i){
            if(dp[i&1][a][b]==false)continue;
            if(abs(x[i]-x[a])+abs(y[i]-y[a])<=s[i]-t[a])dp[(i+1)&1][b][i-1]=true;
            if(abs(x[i]-x[b])+abs(y[i]-y[b])<=s[i]-t[b])dp[(i+1)&1][a][i-1]=true;

            if(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])<=s[i]-t[i-1])dp[(i+1)&1][a][b]=true;
            dp[i&1][a][b]=false;
        }
    }

    rep(a,N+M-1)rrep(b,a+1,N+M-1){
        if(dp[(N+M)&1][a][b]){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

提出情報

提出日時
問題 D - ラボライブ タフグローバルフェスティバル
ユーザ zerosun
言語 C++ (GCC 4.9.2)
得点 0
コード長 2746 Byte
結果 TLE
実行時間 2033 ms
メモリ 2856 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:51:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     int M;scanf("%d",&M);
                         ^
./Main.cpp:54:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",x+i,y+i);
                              ^
./Main.cpp:57:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     int N;scanf("%d",&N);
                         ^
./Main.cpp:58:54: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     rep(i,N)scanf("%d%d%d%d",x+i+M,y+i+M,s+i+M,t+i+M);
                                                      ^

ジャッジ結果

セット名 All
得点 / 配点 0 / 200
結果
AC × 52
TLE × 2
セット名 テストケース
All scrambled_00.txt, scrambled_01.txt, scrambled_02.txt, scrambled_03.txt, scrambled_04.txt, scrambled_05.txt, scrambled_06.txt, scrambled_07.txt, scrambled_08.txt, scrambled_09.txt, scrambled_10.txt, scrambled_11.txt, scrambled_12.txt, scrambled_13.txt, scrambled_14.txt, scrambled_15.txt, scrambled_16.txt, scrambled_17.txt, scrambled_18.txt, scrambled_19.txt, scrambled_20.txt, scrambled_21.txt, scrambled_22.txt, scrambled_23.txt, scrambled_24.txt, scrambled_25.txt, scrambled_26.txt, scrambled_27.txt, scrambled_28.txt, scrambled_29.txt, scrambled_30.txt, scrambled_31.txt, scrambled_32.txt, scrambled_33.txt, scrambled_34.txt, scrambled_35.txt, scrambled_36.txt, scrambled_37.txt, scrambled_38.txt, scrambled_39.txt, scrambled_40.txt, scrambled_41.txt, scrambled_42.txt, scrambled_43.txt, scrambled_44.txt, scrambled_45.txt, scrambled_46.txt, scrambled_47.txt, scrambled_48.txt, scrambled_49.txt, scrambled_50.txt, scrambled_51.txt, scrambled_52.txt, scrambled_53.txt
ケース名 結果 実行時間 メモリ
scrambled_00.txt AC 25 ms 800 KiB
scrambled_01.txt AC 25 ms 804 KiB
scrambled_02.txt AC 24 ms 928 KiB
scrambled_03.txt AC 245 ms 2724 KiB
scrambled_04.txt AC 246 ms 2728 KiB
scrambled_05.txt AC 245 ms 2724 KiB
scrambled_06.txt TLE 2032 ms 2856 KiB
scrambled_07.txt TLE 2033 ms 2856 KiB
scrambled_08.txt AC 24 ms 928 KiB
scrambled_09.txt AC 25 ms 796 KiB
scrambled_10.txt AC 25 ms 736 KiB
scrambled_11.txt AC 25 ms 808 KiB
scrambled_12.txt AC 23 ms 804 KiB
scrambled_13.txt AC 24 ms 808 KiB
scrambled_14.txt AC 25 ms 924 KiB
scrambled_15.txt AC 25 ms 736 KiB
scrambled_16.txt AC 25 ms 928 KiB
scrambled_17.txt AC 25 ms 800 KiB
scrambled_18.txt AC 26 ms 752 KiB
scrambled_19.txt AC 25 ms 732 KiB
scrambled_20.txt AC 26 ms 924 KiB
scrambled_21.txt AC 25 ms 928 KiB
scrambled_22.txt AC 24 ms 924 KiB
scrambled_23.txt AC 25 ms 748 KiB
scrambled_24.txt AC 25 ms 928 KiB
scrambled_25.txt AC 147 ms 924 KiB
scrambled_26.txt AC 25 ms 928 KiB
scrambled_27.txt AC 32 ms 928 KiB
scrambled_28.txt AC 23 ms 920 KiB
scrambled_29.txt AC 94 ms 804 KiB
scrambled_30.txt AC 26 ms 920 KiB
scrambled_31.txt AC 112 ms 792 KiB
scrambled_32.txt AC 26 ms 796 KiB
scrambled_33.txt AC 189 ms 788 KiB
scrambled_34.txt AC 27 ms 920 KiB
scrambled_35.txt AC 25 ms 916 KiB
scrambled_36.txt AC 25 ms 920 KiB
scrambled_37.txt AC 27 ms 920 KiB
scrambled_38.txt AC 27 ms 796 KiB
scrambled_39.txt AC 25 ms 924 KiB
scrambled_40.txt AC 25 ms 836 KiB
scrambled_41.txt AC 26 ms 920 KiB
scrambled_42.txt AC 27 ms 920 KiB
scrambled_43.txt AC 26 ms 920 KiB
scrambled_44.txt AC 25 ms 732 KiB
scrambled_45.txt AC 25 ms 916 KiB
scrambled_46.txt AC 26 ms 920 KiB
scrambled_47.txt AC 25 ms 796 KiB
scrambled_48.txt AC 27 ms 916 KiB
scrambled_49.txt AC 24 ms 916 KiB
scrambled_50.txt AC 25 ms 796 KiB
scrambled_51.txt AC 24 ms 916 KiB
scrambled_52.txt AC 28 ms 920 KiB
scrambled_53.txt AC 26 ms 916 KiB