# Include <iostream> # include <cstdio> # include <algorithm> using namespace STD; int flg [1001]; // tag coin: 0: initial status; 1: suspicious; 2: normal coin int comp [100] [1001]; // store the char res [100] During the comparison process; // store the comparison result int sumarray (int * arr, int start, int end, int FAL, int value) // FAL is a faulty coin and its corresponding value {int sum = 0; For (INT I = start; I <= end; ++ I) if (ARR [I]! = FAL) sum + = 2; // The normal coin value is 2 elsesum + = value; return sum;} int main () {freopen ("in.txt", "r ", stdin); memset (flg, 0, sizeof (INT) * 1001); int N, // 2 <= n <= 1000 K; // 1 <= k <= 100int Index = 0; CIN> N> K; while (k --) {CIN> comp [Index] [0]; for (INT I = 1; I <= 2 * comp [Index] [0]; ++ I) {CIN> comp [Index] [I]; if (flg [comp [Index] [I]! = 2) flg [comp [Index] [I] = 1;} CIN> res [Index]; If (RES [Index] = ') {for (INT I = 1; I <= 2 * comp [Index] [0]; ++ I) flg [comp [Index] [I] = 2 ;} + + index;} int I, j, k; int left, right; int fcoin =-1; // record fcoinchar ch; for (I = 1; I <= N; ++ I) {If (flg [I] = 1) {for (j = 1; j <= 3; j + = 2) // The possible value of the faulty coin is 1, 3 {for (k = 0; k <index; ++ K) {left = sumarray (Comp [K], 1, comp [k] [0], I, j); Right = sumarray (Comp [K], comp [k] [0] + 1, 2 * comp [k] [0], i, j); If (L EFT <right) CH = '<'; else if (Left = right) CH = '; else CH ='> '; If (Ch! = Res [k]) break;} If (k = index) {If (fcoin =-1) fcoin = I; else // multiple coins that match all the conditions {fcoin =-2; goto end ;}}}end: If (fcoin> 0) cout <fcoin <Endl; else if (fcoin =-2) cout <0 <Endl; else if (fcoin =-1) // in special cases, that is, N count, sure there is no problem with the number of N-1, then the last coin is faulty {int COUNT = 0, T; For (INT I = 1; I <= N; ++ I) if (flg [I] = 0) {+ + count; t = I;} If (COUNT = 1) cout <t <Endl; elsecout <0 <Endl ;}}
Test data:
5 2
1 2 3
=
1 1 4
=
5 3
2 1 2 3 4
>
1 1 4
=
1 2 5
=
2 2
1 1 2
<
1 2 1
>
5 3
2 1 2 3 4
>
1 1 4
=
1 2 5
=
This question is too tangled. The submission always shows a running error, and it is not depressing. The final result is that the question number is incorrect at the time of submission. It should be 1029. It is actually 1019, fuck !!