Submission #7202678

Source Code Expand

using namespace std;
namespace mine
    #define double long double
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define SZ(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    ll qread()
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    void write(ll num)
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    void chmax(int &x,const ll y) {x=(x>y?x:y);}
    void chmin(int &x,const ll y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):0;}
    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    inline ll qpower(ll x,ll e)
        ll ans=1;
            if(e&1) ans=ans*x%MOD;
        return ans;
    inline int invm(int x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    char str[N];int cnt[N];
    void to(int &x,int &y){if(x) y++,x--;}
    void main()
        int n=qread();ll ans=1;for(int i=2;i<=n;i++) ans=ans*i%MOD;
        for(int i=1;i<=3*n;i++)
            int now=(str[i]=='R'?1:(str[i]=='G'?2:3));
            if(cnt[7-now]) ans=ans*cnt[7-now]%MOD,cnt[7-now]--;
            else if(now==1 and cnt[2]+cnt[3]) ans=ans*(cnt[2]+cnt[3])%MOD,to(cnt[2],cnt[2+now+1]),to(cnt[3],cnt[3+now+1]);
            else if(now==2 and cnt[1]+cnt[3]) ans=ans*(cnt[1]+cnt[3])%MOD,to(cnt[1],cnt[1+now+1]),to(cnt[3],cnt[3+now+1]);
            else if(now==3 and cnt[1]+cnt[2]) ans=ans*(cnt[1]+cnt[2])%MOD,to(cnt[2],cnt[2+now+1]),to(cnt[1],cnt[1+now+1]);
            else cnt[now]++;
            // puts("");
int main()

Submission Info

Submission Time
Task B - RGB Balls
User Zory
Language C++14 (GCC 5.4.1)
Score 800
Code Size 2267 Byte
Exec Time 5 ms
Memory 2432 KB

Compile Error

./Main.cpp: In function ‘void mine::main()’:
./Main.cpp:55:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample01.txt, sample02.txt
All 800 / 800 sample01.txt, sample02.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
in01.txt 5 ms 2432 KB
in02.txt 5 ms 2304 KB
in03.txt 5 ms 2304 KB
in04.txt 5 ms 2304 KB
in05.txt 4 ms 2304 KB
in06.txt 5 ms 2432 KB
in07.txt 5 ms 2432 KB
in08.txt 4 ms 2304 KB
in09.txt 5 ms 2432 KB
in10.txt 5 ms 2432 KB
in11.txt 5 ms 2432 KB
in12.txt 5 ms 2432 KB
in13.txt 5 ms 2432 KB
in14.txt 5 ms 2304 KB
in15.txt 5 ms 2432 KB
in16.txt 5 ms 2432 KB
in17.txt 5 ms 2432 KB
in18.txt 5 ms 2432 KB
in19.txt 5 ms 2432 KB
in20.txt 5 ms 2432 KB
in21.txt 5 ms 2432 KB
in22.txt 4 ms 2432 KB
in23.txt 5 ms 2432 KB
sample01.txt 2 ms 2304 KB
sample02.txt 2 ms 2304 KB