一开始用set存xjb分类讨论,然后wa,

然后简化了一点,改用vector,然wa

最后又发现没有初始化,然wa

wa了一个半小时

最后看了题解orz

然后找了一组样例把自己的代码改对了

/*

1 1
1 1
1 1
1 1
1 2
1 2

*/

正统题解:不妨设三条边为a<=b<=c, 那么对每个面(边对)sort后,必然得到 ab ab ac ac bc bc 然后照着这个序列写六个判断就好了orz

#define _CRT_SECURE_NO_WARNINGS
#include<cmath>
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<stack>
#include<vector>
#include<string.h>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define rep(i,t,n) for(int i =(t);i<=(n);++i)
#define per(i,n,t) for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
#define eps 1e-6
#define pb push_back #define mp make_pair
#define x first
#define y second
pair<int, int> a[];
int main() {
while (cin >> a[].x >> a[].y){ rep(i, , )scanf("%d%d", &a[i].x, &a[i].y);
rep(i, , )if(a[i].x>a[i].y)swap(a[i].x,a[i].y);
sort(a + , a + );
puts(a[] == a[] && a[] == a[] && a[] == a[] && a[].x==a[].x&&a[].y==a[].y&&a[].x==a[].y?"POSSIBLE":"IMPOSSIBLE"); }
}
/*
POSSIBLE
IMPOSSIBLE
*/

第一版代码,先判每个面出现了两遍,再把不同的三个面找出来,按有几个面是正方形分类

#define _CRT_SECURE_NO_WARNINGS
#include <cmath>
#include <iostream>
#include <stdio.h>
#include<algorithm>
#include <map>
#include <cstring>
#include <time.h>
#include <string>
#include <vector>
#include <set>
using namespace std;
#define rep(i,t,n) for(int i =(t);i<=(n);++i)
#define per(i,n,t) for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
const double pi = acos(-1.0);
const int maxn = + ;
int n,m; int main()
{ int x, y; while (cin >> x >> y){
set<int> S[];
vector < set<int>> V;
S[].insert(x), S[].insert(y);
rep(i, , ) { cin >> x >> y;
S[i].insert(x), S[i].insert(y);
}
int f[];
mmm(f, );
int vis[]; mmm(vis, );
rep(i, , )rep(j, , )if (i != j) {
if (S[i] == S[j]) { f[i] = ; if (!vis[i]&&!vis[j]) { V.push_back(S[i]); vis[j] = ; vis[i] = ;} }
}
rep(i, , )if (!f[i]) { f[] = ; }
if (f[] == ) { puts("IMPOSSIBLE"); continue; }
int cnt=;
rep(i, , )if (V[i].size() == )cnt++;
if (cnt == ) { if (V[] == V[] && V[] == V[]) puts("POSSIBLE"); else puts("IMPOSSIBLE"); continue; }
if (cnt == ) {
vector < set<int>> T;
for (auto t : V)if (t.size() == ) { T.push_back(t); }
if(*T.begin()==*T.rbegin()) { puts("POSSIBLE"); continue; }else { puts("IMPOSSIBLE"); continue; }
}
if(cnt==) { puts("IMPOSSIBLE"); continue; }
if (cnt == ) {
int ok = ;
vector < int> T;
rep(i, , )if (*V[].begin() == *V[i].begin())T.push_back(*V[i].rbegin());
else if (*V[].begin() == *V[i].rbegin())T.push_back(*V[i].begin());
rep(i, , )if (*V[].rbegin() == *V[i].begin())T.push_back(*V[i].rbegin());
else if (*V[].rbegin() == *V[i].rbegin())T.push_back(*V[i].begin());
//else ok = 0;
if(T.size()!=){ puts("IMPOSSIBLE"); continue; }
if(T.front()!=T.back()) { puts("IMPOSSIBLE"); continue; }
else { puts("POSSIBLE"); continue; }
}
}
cin >> n;
return ;
}
/* 1 1
2 1
2 1
1 1
1 1
1 1
*/

第二版代码:用vector存,并且简化了分类:要么可以 要么不可能//废话

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,t,n) for(int i =(t);i<=(n);++i)
#define per(i,n,t) for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
int main()
{ int x, y;
while (cin >> x >> y) {
vector < vector<int>> V;
vector<int> v[];
if (x > y)swap(x, y);
v[].push_back(x); v[].push_back(y);
rep(i, , ) { cin >> x >> y;
if (x > y)swap(x, y);
v[i].push_back(x); v[i].push_back(y);
}
int f[]; int vis[]; mmm(vis, );
mmm(f, );
rep(i, , )rep(j, , )if (i != j) {
if (v[i] == v[j]) { f[i] = ; if (!vis[i]&&!vis[j]) { V.push_back(v[i]); vis[j] = ; vis[i] = ;} }
}
rep(i, , )if (!f[i]) { f[] = ; }
if (f[] == ) { puts("IMPOSSIBLE"); continue; }
int ok = ;
int t = ;
int x = ;
if (V[].front() == V[].front())t = V[].back(); else if (V[].front() == V[].back())t = V[].front(); else {
x = ;
if (V[].front() == V[].front())t = V[].back(); else if (V[].front() == V[].back())t = V[].front(); else ok = ;
}
int t2 = ;
if (t == V[x].front())t2 = V[x].back(); else if (t == V[x].back())t2 = V[x].front(); else {
ok = ;
}
if (t2 != V[].back())ok = ;
if (ok)puts("POSSIBLE");
else puts("IMPOSSIBLE");
}
return ;
}

【每日一题】 UVA - 1587 Box 二维有点偏序的感觉的更多相关文章

  1. Java实习生常规技术面试题每日十题Java基础(二)

    目录 1. JAVA 的反射机制的原理. 2.静态嵌套类(Static Nested Class)和内部类(Inner Class)的不同? 3.如何将String类型转化成Number类型. 4.什 ...

  2. BZOJ3132 上帝造题的七分钟 【二维树状数组】

    题目 "第一分钟,X说,要有矩阵,于是便有了一个里面写满了0的n×m矩阵. 第二分钟,L说,要能修改,于是便有了将左上角为(a,b),右下角为(c,d)的一个矩形区域内的全部数字加上一个值的 ...

  3. P4514 上帝造题的七分钟(二维树状数组)

    P4514 上帝造题的七分钟 二维树状数组 差分维护区间加法,区间求和 #include<cstdio> int read(){ ,f=; ') f=f&&(c!='-') ...

  4. UVa 11297 Census (二维线段树)

    题意:给定上一个二维矩阵,有两种操作 第一种是修改 c x y val 把(x, y) 改成 val 第二种是查询 q x1 y1 x2 y2 查询这个矩形内的最大值和最小值. 析:二维线段树裸板. ...

  5. UVA 11297 Census ——二维线段树

    [题目分析] 二维线段树模板题目. 简直就是无比的暴力.时间复杂度为两个log. 标记的更新方式比较奇特,空间复杂度为N^2. 模板题目. [代码] #include <cstdio> # ...

  6. 计算机二级-C语言-程序填空题-190109记录-对二维字符串数组的处理

    //给定程序,函数fun的功能是:求出形参ss所指字符串数组中最长字符串的长度,将其余字符串右边用字符*补齐,使其与最长的字符串等长.ss所指字符串数组中共有M个字符串,且串长<N. //重难点 ...

  7. uva 1587(Box UVA - 1587)

    题目大意是给定6个数对,每个数对代表一个面的长和宽,判断这6个面是否能构成一个长方体. 这种题一看很复杂,但是只要不想多了实际上这就是一个水题... 首先说明一下判断的思路: 1.长方体是有三个对面的 ...

  8. UVa 1587 Box

    题意:给出6个矩形的长和宽,问是否能够构成一个长方体 先假设一个例子 2 3 3 4 2 3 3 4 4 2 4 2 排序后 2 3 2 3 3 4 3 4 4 2 4 2 如果要构成一个长方体的话, ...

  9. BZOJ 3132 上帝造题的七分钟(二维树状数组)

    题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=3132 题意:给出一个矩阵,两种操作:(1)将某个子矩阵的数字统一加上某个值:(2)查询某 ...

随机推荐

  1. Windows 8系统默认开启的.Net Framework版本是4.0,而部分用户可能需要使用到3.5或以下版本,简单添加方法

    从网络途径下载的.Net Framework3.5是无法直接在Windows 8系统上安装的,我们可以通过Windows 8的添加功能来实现 1.打开控制面板,点击”启用或关闭Windows 功能“ ...

  2. [转]Core Kubernetes: Jazz Improv over Orchestration

    (因为写的真的是太好了,所以必须要转载) This is the first in a series of blog posts that details some of the inner work ...

  3. struts2:数据标签

    目录 数据标签1. a标签2. set标签3. push标签4. bean/param标签5. date标签6. include标签7. url标签8. property标签9. debug标签10. ...

  4. 【ZooKeeper】ZooKeeper入门流水记

    单机模式 下载zookeeper的包 wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.ta ...

  5. spring入门常见的问题及解决办法

    在学习spring过程中遇见了种种不同的异常错误,这里做了一下总结,希望遇见类似错误的同学们共勉一下. 1. 错误一 Error creating bean with name 'helloServi ...

  6. 一、Bitcoin比特币与BlockChain区块链技术

    一.比特币历史 2008 年 10 月 31 日,一个网名叫中本聪(英文翻译过来滴)的家伙发布比特币唯一的白皮书:<Bitcoin:A Peer-to-PeerElectronic Cash S ...

  7. highCharts图表入门简介

    一.Highcharts简介 Highcharts:功能强大.开源.美观.图表丰富.兼容绝大多数浏览器的纯js图表库 Highcharts是一款纯javascript编写的图表库,能够很简单便捷的在W ...

  8. [Laravel] 06 - Project: from Usercase to View

    故事背景 一.项目预览 From: https://www.imooc.com/video/12518 二.知识点 通过项目复习之前的重难点,在此列出并解决. /* implement */ 项目开始 ...

  9. android高级---->Handler的原理

    andriod提供了Handler来满足线程间的通信,上次在更新UI的时候也提到过Handler的使用,关于Handler的基本使用,参见博客(android基础---->子线程更新UI).今天 ...

  10. MySql表结构修改详解

    修改表的语法=========================增加列[add 列名]=========================①alter table 表名 add 列名 列类型 列参数[加的 ...