GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — AlgorithmCode/hihocoder/1114/sol.cpp at master · hnulst/AlgorithmCode

Expand file tree

/

sol.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
67 lines (64 loc) · 1.34 KB
/

sol.cpp

Copy path

File metadata and controls

67 lines (64 loc) · 1.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std;
#define MAXN 100010
int b[MAXN];
int x1[MAXN],x2[MAXN],n;
bool f1,f2;
void prt(int t){
vector<int> ans;
for(int i=1;i<=n;i++){
if(f1&&f2){
if(x1[i]==t&&x2[i]==t)ans.push_back(i);
}
else if( f1 ){
if(x1[i]==t) ans.push_back(i);
}
else {
if(x2[i]==t) ans.push_back(i);
}
}
int sz = ans.size();
printf("%d",sz);
for(int i=0;i<sz;i++)
printf(" %d",ans[i]);
printf("\n");
}
int main(){
#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif
int t;
b[0]=0;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&b[i]);
f1=true;f2=true;
int last=1;
x1[1]=1;x1[0]=0;
for(int i=1;i<=n;i++){
x1[i+1]=b[i]-x1[i]-x1[i-1];
if(x1[i]>1||x1[i]<0){
f1=false;
break;
}
}
if(x1[n+1]!=0) f1=false;
x2[1]=0;x2[0]=0;
for(int i=1;i<=n;i++){
x2[i+1]=b[i]-x2[i]-x2[i-1];
if(x2[i]>1||x2[i]<0){
f2=false;
break;
}
}
if(x2[n+1]!=0) f2=false;
prt(1);
prt(0);
}
return 0;
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.