hiho week 80 register

Ended

Participants:173

Verdict:Accepted
Score:100 / 100
Submitted:2016-01-15 11:47:38

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 20005;
typedef pair<int,int> pii;
typedef long long ll;
char s[N];
int x,y,z,cnt[3];
int isMatch(int c0,int c1,int c2){
    int k1 = abs(c0-c1);
    int k2 = abs(c1-c2);
    int k3 = abs(c2-c0);
    return (k1==x&&k2==y&&k3==z)||(k1==x&&k2==z&&k3==y)||
    (k1==y&&k2==x&&k3==z)||(k1==y&&k2==z&&k3==x)||
    (k1==z&&k2==x&&k3==y)||(k1==z&&k2==y&&k3==x);  
}
int main(){
    while(~scanf("%d %d %d",&x,&y,&z)){
        scanf("%s",s);
        int ans = 0;
        memset(cnt,0,sizeof(cnt));
        char *p = s;
        while(*p != '\0'){
            if(*p == 'R') ++cnt[0];
            else if(*p == 'Y') ++cnt[1];
            else ++cnt[2];
            if(isMatch(cnt[0],cnt[1],cnt[2])){
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX