結果

問題 No.1436 Rgaph
ユーザー qwewe
提出日時 2025-05-14 13:26:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 978 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 59,904 KB
最終ジャッジ日時 2025-05-14 13:27:19
合計ジャッジ時間 5,559 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    N, M = map(int, sys.stdin.readline().split())
    # Edges are read but not used in this specific logic,
    # as the problem asks for *a* coloring if one exists.
    # The condition M%2 seems to be the dominant factor based on problem type and examples.
    for _ in range(M):
        sys.stdin.readline() # Consume edge data

    if M % 2 != 0:
        print("-1")
    else:
        # For M even, alternate R and G.
        # Railway i (1-indexed) is R if i is odd, G if i is even.
        # This corresponds to 0-indexed S[j] being R if j is even, G if j is odd.
        result_chars = []
        for i in range(M):
            if i % 2 == 0: # 0-indexed: 0, 2, 4... -> R (corresponds to railway 1, 3, 5...)
                result_chars.append('R')
            else: # 0-indexed: 1, 3, 5... -> G (corresponds to railway 2, 4, 6...)
                result_chars.append('G')
        print("".join(result_chars))

if __name__ == '__main__':
    main()
0