[HIHO1223]不等式(离散化,枚举)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[HIHO1223]不等式(离散化,枚举)相关的知识,希望对你有一定的参考价值。

题目链接:http://hihocoder.com/problemset/problem/1223

这题不难,难点在于小数的处理。可以0.5为步长枚举,也可以扩大偶数倍枚举。

  1 /*
  2 ━━━━━┒ギリギリ♂ eye!
  3 ┓┏┓┏┓┃キリキリ♂ mind!
  4 ┛┗┛┗┛┃\○/
  5 ┓┏┓┏┓┃ /
  6 ┛┗┛┗┛┃ノ)
  7 ┓┏┓┏┓┃
  8 ┛┗┛┗┛┃
  9 ┓┏┓┏┓┃
 10 ┛┗┛┗┛┃
 11 ┓┏┓┏┓┃
 12 ┛┗┛┗┛┃
 13 ┓┏┓┏┓┃
 14 ┃┃┃┃┃┃
 15 ┻┻┻┻┻┻
 16 */
 17 #include <algorithm>
 18 #include <iostream>
 19 #include <iomanip>
 20 #include <cstring>
 21 #include <climits>
 22 #include <complex>
 23 #include <cassert>
 24 #include <cstdio>
 25 #include <bitset>
 26 #include <vector>
 27 #include <deque>
 28 #include <queue>
 29 #include <stack>
 30 #include <ctime>
 31 #include <set>
 32 #include <map>
 33 #include <cmath>
 34 using namespace std;
 35 #define fr first
 36 #define sc second
 37 #define cl clear
 38 #define BUG puts("here!!!")
 39 #define W(a) while(a--)
 40 #define pb(a) push_back(a)
 41 #define Rint(a) scanf("%d", &a)
 42 #define Rll(a) scanf("%I64d", &a)
 43 #define Rs(a) scanf("%s", a)
 44 #define Cin(a) cin >> a
 45 #define FRead() freopen("in", "r", stdin)
 46 #define FWrite() freopen("out", "w", stdout)
 47 #define Rep(i, len) for(int i = 0; i < (len); i++)
 48 #define For(i, a, len) for(int i = (a); i < (len); i++)
 49 #define Cls(a) memset((a), 0, sizeof(a))
 50 #define Clr(a, x) memset((a), (x), sizeof(a))
 51 #define Full(a) memset((a), 0x7f7f7f, sizeof(a))
 52 #define lrt rt << 1
 53 #define rrt rt << 1 | 1
 54 #define pi 3.14159265359
 55 #define RT return
 56 #define lowbit(x) x & (-x)
 57 #define onenum(x) __builtin_popcount(x)
 58 typedef long long LL;
 59 typedef long double LD;
 60 typedef unsigned long long ULL;
 61 typedef pair<int, int> pii;
 62 typedef pair<string, int> psi;
 63 typedef pair<LL, LL> pll;
 64 typedef map<string, int> msi;
 65 typedef vector<int> vi;
 66 typedef vector<LL> vl;
 67 typedef vector<vl> vvl;
 68 typedef vector<bool> vb;
 69 
 70 typedef struct Node {
 71     char p[5];
 72     int c;
 73 }Node;
 74 
 75 const int maxn = 1100;
 76 int n;
 77 char qx[5];
 78 Node k[maxn];
 79 
 80 int main() {
 81     // FRead();
 82     while(~Rint(n)) {
 83         Cls(k);
 84         For(i, 1, n+1) {
 85             Rs(qx); Rs(k[i].p); Rint(k[i].c);
 86             k[i].c <<= 2;
 87         }
 88         int ret = 0;
 89         For(x, -1005, 4005) {
 90             int cur = 0;
 91             For(i, 1, n+1) {
 92                 int len = strlen(k[i].p);
 93                 if(k[i].p[0] == < && len == 1)
 94                     if(x < k[i].c) cur++;
 95                 if(k[i].p[0] == < && k[i].p[1] == =)
 96                     if(x <= k[i].c) cur++;
 97                 if(k[i].p[0] == = && len == 1)
 98                     if(x == k[i].c) cur++;
 99                 if(k[i].p[0] == > && len == 1)
100                     if(x > k[i].c) cur++;
101                 if(k[i].p[0] == > && k[i].p[1] == =)
102                     if(x >= k[i].c) cur++;
103             }
104             ret = max(ret, cur);
105         }
106         printf("%d\n", ret);
107     }
108     RT 0;
109 }

 

以上是关于[HIHO1223]不等式(离散化,枚举)的主要内容,如果未能解决你的问题,请参考以下文章

hiho1079 线段树区间改动离散化

[HIHO1079]离散化(线段树染色)

hiho_1079_离散化

hihocoder-1223-不等式

bzoj4195(并查集+离散化)

BZOJ 4195: [Noi2015]程序自动分析 [并查集 离散化 | 种类并查集WA]