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 | ||
| #1 | Accepted | 1ms | 524 KiB |
| #2 | Accepted | 1ms | 504 KiB |
| #3 | Accepted | 1ms | 504 KiB |
| #4 | Accepted | 1ms | 504 KiB |
| #5 | Accepted | 1ms | 504 KiB |
| #6 | Accepted | 3ms | 760 KiB |
| #7 | Accepted | 3ms | 704 KiB |
| #8 | Accepted | 3ms | 760 KiB |
| #9 | Accepted | 1ms | 388 KiB |
| #10 | Accepted | 1ms | 504 KiB |
| #11 | Accepted | 1ms | 520 KiB |
| #12 | Accepted | 1ms | 504 KiB |
| #13 | Accepted | 2ms | 504 KiB |
| #14 | Accepted | 3ms | 792 KiB |
| #15 | Accepted | 2ms | 500 KiB |
| #16 | Accepted | 1ms | 504 KiB |
| #17 | Accepted | 1ms | 624 KiB |
| #18 | Accepted | 2ms | 504 KiB |
| #19 | Accepted | 1ms | 576 KiB |
| #20 | Accepted | 1ms | 572 KiB |
| #21 | Accepted | 2ms | 504 KiB |
| #22 | Accepted | 1ms | 572 KiB |
| #23 | Accepted | 3ms | 760 KiB |
| #24 | Accepted | 3ms | 764 KiB |
| #25 | Accepted | 3ms | 632 KiB |
代码
#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