Home > Back-end >  Codechef on a problem, ask for help
Codechef on a problem, ask for help

Time:03-12

Idea is to check whether the input data after input legitimate (lost) or the first one way, then the accumulative sum of input data and then 1 + 2 +... + N sumN is take over, don't know what is wrong,
 
# include & lt; Bits/stdc++. H>
using namespace std;

Int main () {
Unsigned int T;
Long long N;
Long long sum=0, sumN=0;
Int sign=1;
Cin & gt;> T;
Int ans [T];
for (int i=0; I & lt; T; + + I) {
Cin & gt;> N;
Vector Num.
Long long input;
Sum=sumN=0;
Sign=1;
Unsigned int numCount [N]={0};
For (int j=1; J & lt;=N; SumN +=j + + j);
For (int j=0; J & lt; N; + + j) {
Cin & gt;> The input;
Num. Push_back (input);
NumCount [num [j] - 1] + +;
}
Unsigned int numCountAll=0;
For (int j=N - 1; J & gt;=0; - j) {
NumCountAll +=numCount [j];
If (numCountAll & gt; N - j) {
Sign=0;
break;
}
}
If (sign==0) {
Ans [I]=0;
} else {
For (int j=0; J & lt; N; + + j) {
The sum + num=[j];
}
Int sub=sumN - sum;
If (sub % 2==1) {
Ans [I]=1;
} else {
Ans [I]=0;
}
}
}
for (int i=0; I & lt; T; + + I) {
If (ans [I]) {
Printf (" First \ n ");
} else {
Printf (" Second \ n ");
}
}
return 0;
}



  • Related