一开始用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. mechanize (1)

    最近看的关于网络爬虫和模拟登陆的资料,发现有这样一个包 mechanize ['mekə.naɪz]又称为机械化的意思,确实文如其意,确实有自动化的意思. mechanize.Browser and ...

  2. SNF开发平台WinForm之十五-时间轴控件使用-SNF快速开发平台3.3-Spring.Net.Framework

    一.显示效果如下: 二.在控件库里选择UCTimeAxis 拖拽到窗体里. 三.加入以下代码,在load事件里进行调用就可以运行了. #region 给时间轴控件加载数据 private void U ...

  3. LayaBox IDE 安装后执行项目报错解决方案的一些记录

    1.打开IDE后出现“路径xxx未指向有效地tsserver安装.将禁用TypeScript语言功能.”提示: 这是由于杀毒软件吧ts对应的js文件作为病毒删除导致的,一般到杀毒软件的历史界面中将ts ...

  4. linux source code search

    https://elixir.bootlin.com/linux/latest/source/fs/eventpoll.c#L1120

  5. pandas的qcut()方法

    pandas的qcut可以把一组数字按大小区间进行分区,比如 data = pd.Series([0,8,1,5,3,7,2,6,10,4,9]) 比如我要把这组数据分成两部分,一半大的,一半小的,如 ...

  6. 【Linux高级驱动】I2C驱动框架分析

    1.i2c-dev.c(i2c设备驱动组件层) 功能:1)给用户提供接口 i2c_dev_init  //入口函数 /*申请主设备号*/ register_chrdev(I2C_MAJOR(), &q ...

  7. post请求数据量过大,提交失败

    HttpRuntimeSection.MaxRequestLength 属性,请求的最大大小(以千字节为单位). 默认大小为 4096 KB (4 MB) <system.web> < ...

  8. python调用nmap探测局域网设备

    平台:linux 描述:利用os.popen()函数调用系统命令nmap进行扫描,并用grep命令对扫描结果关键内容进行提取 代码 #!/usr/bin/env pthon #--*--coding= ...

  9. 我在tmux中最不可少的配置: 用鼠标切换窗口/调节分屏大小

    前两天在给另外一个团队帮忙时,看他们在Rails日志.代码文件.git文件系统里面来回穿梭,觉得他们太累了,于是就介绍了 tmux 给他们用.但只讲了一点基本的开窗口.分屏,没给讲太多技巧,因为一下子 ...

  10. android开发(48) Android Snackbar 的使用

    Snackbar 类似toast,用于向 用户展示信息,和用户交互,它能够显示一个 按钮 获得用户的操作.它的特点如下: 作为android.support.design.widget.Coordin ...