1 条题解
-
0Guest LV 0 MOD
-
0
#include<bits/stdc++.h> using namespace std; int a[2][20000]; int main() { int n; scanf("%d",&n); for (int i=1; i<=n; ++i) scanf("%d%d",&a[0][i],&a[1][i]); int x=1,y=0,ans=0; while (x<n){ if (a[y][x] || (a[0][x+1] && a[1][x+1])){ ans=-1; break; } if (a[y][x+1]) { y^=1; ++ans; continue; } ++ans; ++x; } if (ans==-1) printf("No"); else printf("%d\n",ans); return 0; }
- 1