题解 CF1173A 【Nauuo and Votes】

· · 题解

这道题一看就知道是要模拟,那么按照题目意思操作即可

1.如果有“赞”的人数一定多于“踩”的人数,结果将是“+”,那么假设最坏的情况:不确定的人全部选“踩”,如果此时选“赞”的人数仍然多于“踩”的人数,那么可知无论不确定的人选什么,选“赞”的人数都会多于“踩”的人数,因此输出“+”

2.如果有“踩”的人数一定多于“赞”的人数,结果将是“ - ”,判断方式及理由同上

3.否则结果将为“0”,也就是说,如果选“赞”的人数和“踩”的人数必定相等,那么输出“0”。因为不确定者的存在,所以只有没有人的选择不确定且选“赞”的人数和“踩”的人数相等时,选“赞”的人数和“踩”的人数必定相等,此时即输出“0”

4.如果不是以上三种情况,那么就不能确定,输出“?”

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1,ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

int x,y,z;

int main(){
    x = read<int>();
    y = read<int>();
    z = read<int>();
    if(x - z > y) {
        printf("+\n");
    }else if(y - z > x) { 
        printf("-\n");
    }else if(x == y && z == 0) {
        printf("0\n");
    }else printf("?\n");
    return 0;
}