Enumeration 3 ^ 15 cases, different triangles are deduplicated with set.
Add an edge to all segments, move them one by one to the other, and enumerate all the conditions.
Stuck in the past ...........
Include <cstdio> # include <cmath> # include <iostream> # include <algorithm> # include <cstring> # include <set> using namespace std; int a [22]; int n; int sum, ans, flag; struct node {int x, y, z; bool operator <(const node & a) const {if (. x! = X) return a. x <x; if (a. y! = Y) return. y <y; return. z <z ;}}; set <node> s; // custom set void init () {s. clear ();} void dfs (int v0, int v1, int v2, int I) {if (I> = n) return; if (v0 + v1> v2 & v0 + v2> v1 & v1 + v2> v0) {int a1, a2, a3, tmp; node t; a1 = v0; a2 = v1; a3 = v2; if (a2> a3) {swap (a2, a3);} if (a1> a2) {swap (a1, a2 );} if (a2> a3) {swap (a2, a3);} t. x = a1; t. y = a2; t. z = a3; s. insert (t);} // three options for each I If (v0 + v1-a [I]> v2 + a [I]) dfs (v0-a [I], v1, v2 + a [I], I + 1); if (v0 + v2-a [I]> v1 + a [I]) dfs (v0-a [I], v1 + a [I], v2, I + 1); dfs (v0, v1, v2, I + 1);} int main () {int T; cin> T; while (T --) {init (); scanf ("% d", & n); sum = 0; for (int I = 0; I <n; I ++) {scanf ("% d", & a [I]); sum + = a [I];} dfs (sum, 0, 0 ); printf ("% d \ n", s. size () ;}return 0 ;}# include <cstdio >#include <cmath >#include <iostream> # inclu De <algorithm> # include <cstring> # include <set> using namespace std; int a [22]; int n; int sum, ans, flag; struct node {int x, y, z; bool operator <(const node & a) const {if (. x! = X) return a. x <x; if (a. y! = Y) return. y <y; return. z <z ;}}; set <node> s; // custom setvoid init () {s. clear ();} void dfs (int v0, int v1, int v2, int I) {if (I> = n) return; if (v0 + v1> v2 & v0 + v2> v1 & v1 + v2> v0) {int a1, a2, a3, tmp; node t; a1 = v0; a2 = v1; a3 = v2; if (a2> a3) {swap (a2, a3);} if (a1> a2) {swap (a1, a2 );} if (a2> a3) {swap (a2, a3);} t. x = a1; t. y = a2; t. z = a3; s. insert (t);} // For each I, select if (v0 + v1-a [I]> v2 + a [I]) dfs (v0-a [I], v1, v2 + a [I], I + 1); if (v0 + v2-a [I]> v1 + a [I]) dfs (v0-a [I], v1 + a [I], v2, I + 1); dfs (v0, v1, v2, I + 1 );} int main () {int T; cin> T; while (T --) {init (); scanf ("% d", & n); sum = 0; for (int I = 0; I <n; I ++) {scanf ("% d", & a [I]); sum + = a [I];} dfs (sum, 0, 0); printf ("% d \ n", s. size () ;}return 0 ;}