foo.cc: In function 'void dfs(int, int, int)': foo.cc:8:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation] 8 | if(a[pos]==0) newx=0; if(a[pos]==1||a[pos]==2) newx=15; | ^~ foo.cc:8:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if' 8 | if(a[pos]==0) newx=0; if(a[pos]==1||a[pos]==2) newx=15; | ^~ foo.cc:9:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation] 9 | if(a[pos]==3||x==4) newx=x-1; if(a[pos]==5) newx=x; | ^~ foo.cc:9:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if' 9 | if(a[pos]==3||x==4) newx=x-1; if(a[pos]==5) newx=x; | ^~ foo.cc:10:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation] 10 | if(a[pos]==6) newx=x+1; if(a[pos]==7) newx=x+3; | ^~ foo.cc:10:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if' 10 | if(a[pos]==6) newx=x+1; if(a[pos]==7) newx=x+3; | ^~
| # | 状态 分数 | 耗时 | 内存占用 |
|---|---|---|---|
| (1) | Accepted 100 |
代码
#include<bits/stdc++.h>
#define N 100100
using namespace std;
int n,a[N],ans;
void dfs(int pos,int x,int dep){
if(pos>1&&x==0) return;
if(pos>n){ans=max(ans,dep);return;} int newx;
if(a[pos]==0) newx=0; if(a[pos]==1||a[pos]==2) newx=15;
if(a[pos]==3||x==4) newx=x-1; if(a[pos]==5) newx=x;
if(a[pos]==6) newx=x+1; if(a[pos]==7) newx=x+3;
dfs(pos*2,newx,dep+1),dfs(pos*2+1,newx,dep+1);
}
int main(){
freopen("traversal.in","r",stdin),freopen("traversal.out","w",stdout);
cin>>n; for(int i=1;i<=n;i++) cin>>a[i];
dfs(1,0,0); cout<<ans<<endl;
}
信息
- 递交者
- 题目
- 237 [Sleeping Cup #10] Signal Traversal
- 比赛
- Sleeping Cup #10 (RZOI Round 1 / 2026 April Fool's Day Contest) [Rated by Level 5]
- 语言
- C++11(O2)
- 代码长度
- 550 Bytes
- 递交时间
- 2026-4-5 13:10:36
- 评测时间
- 2026-4-5 13:10:41
- 分数
- 100
- 总耗时
- 41ms
- 峰值时间
- 3ms
- 峰值内存
- 792 KiB