请问各位大佬,为什么我的WA了?

P1152 欢乐的跳

我4,5,6,8这几个点没过QwQ
by 我是坤坤 @ 2019-05-02 11:17:29


相邻数产生的绝对值并不连续,不能这么写吧
by 空江白叶 @ 2019-05-02 11:26:45


@[空江白叶](/space/show?uid=113804) 那请问该怎么改呢?
by 我是坤坤 @ 2019-05-02 11:27:23


```cpp #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[1001]; bool v[1001]; int main() { int n;cin>>n; for(int i=1;i<=n;++i) { cin>>a[i]; if(i>=2) { int A=abs(a[i]-a[i-1]);//abs求绝对值 if(A>n-1||A==0){puts("Not jolly");return 0;} if(v[A]){puts("Not jolly");return 0;} } } puts("Jolly"); return 0; } ```
by 空江白叶 @ 2019-05-02 11:27:51


楼上忘加v[A]=true了
by 142857cs @ 2019-05-02 11:28:57


不用
by songyihang @ 2019-05-02 11:29:16


这样的话,万一差值重复而不连续...
by Fatalis_Lights @ 2019-05-02 11:29:16


@[142857cs](/space/show?uid=35760) 不是一样的意思么。。。
by 空江白叶 @ 2019-05-02 11:29:42


if(v[a])本来就是判断它是不是为真的
by songyihang @ 2019-05-02 11:29:53


``` #include <iostream> using namespace std; int main() { long long n,a[10001],j=0; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=n-1;i>0;i--){ if(j+i<n){ if(abs(a[j]-a[j+1]<=n-1||abs(a[j]-a[j+1]=0){ j++; }else{ cout<<"Not jolly"<<endl; return 0; } } } cout<<"Jolly"<<endl; return 0; } ``` 这样吗?
by 我是坤坤 @ 2019-05-02 11:30:02


| 下一页