正文
增加 24 行删除 24 行
73 行未改动747576777879808182838485868788899091929394959697989910010110210315 行未改动11912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420573 行未改动bool ok = true;struct node{int x[4], y[4];bool operator < (const node &b) const{if(x[1] ^ b.x[1]){return x[1] < b.x[1];}if(x[2] ^ b.x[2]){return x[2] < b.x[2];}if(x[3] ^ b.x[3]){return x[3] < b.x[3];}if(y[1] ^ b.y[1]){return y[1] < b.y[1];}if(y[2] ^ b.y[2]){return y[2] < b.y[2];}return y[3] < b.y[3];}}emp;15 行未改动from[start] = {emp, -1};while(!q.empty()){node s = q.fr();q.pop();if(max({s.x[1], s.x[2], s.x[3]}) < -10) continue;if(max({s.y[1], s.y[2], s.y[3]}) < -10) continue;if(min({s.x[1], s.x[2], s.x[3]}) >= 5 && min({s.y[1], s.y[2], s.y[3]}) >= 5){node res = s;while(1){int i = from[s].sec;if(i == -1) break;f.pb({i % 3 + 1, (i + 1) % 3 + 1, i});//另外两个s = from[s].fir;}return res;}rep(i, 1, 3){node now = s;now.x[i] = (s.x[1] + s.x[2] + s.x[3]) - 2 * s.x[i];//根据中点坐标公式得出来的,推一下就好了now.y[i] = (s.y[1] + s.y[2] + s.y[3]) - 2 * s.y[i];if(!from.count(now)){from[now] = {s, i};q.push(now);}}}}bool check(PII a, PII b, PII c){//叉积判是否在一条直线return (LL)a.fir * (b.sec - c.sec) + (LL)b.fir * (c.sec - a.sec) + (LL)c.fir * (a.sec - b.sec) == 0;}signed main(){ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);cin >> n;rep(i, 1, n){cin >> x[i] >> y[i];id[i] = i;if(x[i] < 0 || y[i] < 0) ok = false;}if(ok){cout << "0";return 0;}rep(i, 3, n){if(!check({x[1], y[1]}, {x[2], y[2]}, {x[i], y[i]})){//不共线才能搜swap(id[3], id[i]);swap(x[3], x[i]);swap(y[3], y[i]);ok = true;break;}}if(!ok){cout << "-1\n";return 0;}node s = BFS();reverse(all(f));rep(i, 4, n){if(x[i] >= 0 && y[i] >= 0) continue;if(!check({s.x[1], s.y[1]}, {s.x[2], s.y[2]}, {x[i], y[i]})) f.pb({1, 2, i});//检查共线情况else f.pb({1, 3, i});}cout << f.size() << "\n";each2(tmp, f){cout << id[tmp.a] << " " << id[tmp.b] << " " << id[tmp.c] << "\n";}return 0;}```我想要天天說,天天說,天天對你說,我有多愛你…………73 行未改动747576777879808182838485868788899091929394959697989910010110210315 行未改动11912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420573 行未改动bool ok = true;struct node{int x[4], y[4];bool operator < (const node &b) const{if(x[1] ^ b.x[1]){return x[1] < b.x[1];}if(x[2] ^ b.x[2]){return x[2] < b.x[2];}if(x[3] ^ b.x[3]){return x[3] < b.x[3];}if(y[1] ^ b.y[1]){return y[1] < b.y[1];}if(y[2] ^ b.y[2]){return y[2] < b.y[2];}return y[3] < b.y[3];}}emp;15 行未改动from[start] = {emp, -1};while(!q.empty()){node s = q.fr();q.pop();if(max({s.x[1], s.x[2], s.x[3]}) < -10) continue;if(max({s.y[1], s.y[2], s.y[3]}) < -10) continue;if(min({s.x[1], s.x[2], s.x[3]}) >= 5 && min({s.y[1], s.y[2], s.y[3]}) >= 5){node res = s;while(1){int i = from[s].sec;if(i == -1) break;f.pb({i % 3 + 1, (i + 1) % 3 + 1, i});//另外两个s = from[s].fir;}return res;}rep(i, 1, 3){node now = s;now.x[i] = (s.x[1] + s.x[2] + s.x[3]) - 2 * s.x[i];//根据中点坐标公式得出来的,推一下就好了now.y[i] = (s.y[1] + s.y[2] + s.y[3]) - 2 * s.y[i];if(!from.count(now)){from[now] = {s, i};q.push(now);}}}}bool check(PII a, PII b, PII c){//叉积判是否在一条直线return (LL)a.fir * (b.sec - c.sec) + (LL)b.fir * (c.sec - a.sec) + (LL)c.fir * (a.sec - b.sec) == 0;}signed main(){ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);cin >> n;rep(i, 1, n){cin >> x[i] >> y[i];id[i] = i;if(x[i] < 0 || y[i] < 0) ok = false;}if(ok){cout << "0";return 0;}rep(i, 3, n){if(!check({x[1], y[1]}, {x[2], y[2]}, {x[i], y[i]})){//不共线才能搜swap(id[3], id[i]);swap(x[3], x[i]);swap(y[3], y[i]);ok = true;break;}}if(!ok){cout << "-1\n";return 0;}node s = BFS();reverse(all(f));rep(i, 4, n){if(x[i] >= 0 && y[i] >= 0) continue;if(!check({s.x[1], s.y[1]}, {s.x[2], s.y[2]}, {x[i], y[i]})) f.pb({1, 2, i});//检查共线情况else f.pb({1, 3, i});}cout << f.size() << "\n";each2(tmp, f){cout << id[tmp.a] << " " << id[tmp.b] << " " << id[tmp.c] << "\n";}return 0;}```我想要天天說,天天說,天天對你說,我有多愛你…………