Question Link
A given Array records the score difference between two teams, with only a score difference. It does not indicate who is tall or who is low, and asks how many possible scores are finally scored.
Analysis:
Similar to the question of CF, I didn't think about it during the competition. It was so stupid .....
1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <cstdlib> 5 # include <cmath> 6 # include <vector> 7 # include <algorithm> 8 # define ll _ int64 9 const int maxn = 100000 + 10; 10 using namespace STD; 11 int A [maxn]; 12 13 int main () 14 {15 int I, t, n, CA = 1, ANS, F; 16 scanf ("% d", & T); 17 while (t --) 18 {19 ans = 0; F = 0; 20 scanf ("% d ", & N); 21 for (I = 1; I <= N; I ++) 22 {23 scanf ("% d", & A [I]); 24 if (I> = 2) 25 {26 if (a [I-1] = 1 & A [I] = 2) 27 ans ++; 28 if (a [I-1] = 2 & A [I] = 1) 29 ans ++; 30 if (a [I-1] = A [I] & A [I]! = 1) // these two are not compliant with the rule 31 f = 1; 32 If (ABS (A [I]-A [I-1])> 3) 33 F = 1; 34} 35} 36 IF (f) 37 printf ("case # % d: 0 \ n", CA ++ ); // null case 38 else if (a [n] = 0) 39 printf ("case # % d: % d \ n", CA ++, ans + 1); // the final score difference is 0, and the result is half less. 40 else41 printf ("case # % d: % d \ n", CA ++, 2 * ans + 2); 42} 43 return 0; 44}