結果

問題 No.2924 <===Super Spaceship String===>
ユーザー lif4635lif4635
提出日時 2024-10-13 02:27:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 3,064 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 117,252 KB
最終ジャッジ日時 2024-10-16 17:56:10
合計ジャッジ時間 1,874 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,608 KB
testcase_01 AC 39 ms
52,992 KB
testcase_02 AC 39 ms
52,992 KB
testcase_03 AC 39 ms
52,864 KB
testcase_04 AC 38 ms
52,864 KB
testcase_05 AC 40 ms
52,736 KB
testcase_06 AC 38 ms
52,864 KB
testcase_07 AC 52 ms
61,312 KB
testcase_08 AC 52 ms
61,312 KB
testcase_09 AC 66 ms
68,224 KB
testcase_10 AC 158 ms
117,252 KB
testcase_11 AC 95 ms
81,972 KB
testcase_12 AC 68 ms
68,696 KB
testcase_13 AC 115 ms
105,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""input"""
#int-input
# input = sys.stdin.readline
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
#str-input
def SI(): return input()
def MSI(): return input().split()
def SI_L(): return list(SI())
def SI_LI(): return list(map(int, SI()))
#multiple-input
def LLI(n): return [LI() for _ in range(n)]
def LSI(n): return [SI() for _ in range(n)]
#1-indexを0-indexでinput
def MI_1(): return map(lambda x:int(x)-1, input().split())
def TI_1(): return tuple(MI_1())
def LI_1(): return list(MI_1())

class dsu():
    n=1
    parent_or_size=[-1 for i in range(n)]
    def __init__(self,N):
        self.n=N
        self.parent_or_size=[-1 for i in range(N)]
    def merge(self,a,b):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n)
        x=self.leader(a)
        y=self.leader(b)
        if x==y:
            return x
        if (-self.parent_or_size[x]<-self.parent_or_size[y]):
            x,y=y,x
        self.parent_or_size[x]+=self.parent_or_size[y]
        self.parent_or_size[y]=x
        return x
    def same(self,a,b):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n)
        return self.leader(a)==self.leader(b)
    def leader(self,a):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        if (self.parent_or_size[a]<0):
            return a
        self.parent_or_size[a]=self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]
    def size(self,a):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        return -self.parent_or_size[self.leader(a)]
    def groups(self):
        leader_buf=[0 for i in range(self.n)]
        group_size=[0 for i in range(self.n)]
        for i in range(self.n):
            leader_buf[i]=self.leader(i)
            group_size[leader_buf[i]]+=1
        result=[[] for i in range(self.n)]
        for i in range(self.n):
            result[leader_buf[i]].append(i)
        result2=[]
        for i in range(self.n):
            if len(result[i])>0:
                result2.append(result[i])
        return result2

s = SI()
n = len(s)

st = []
for i in range(n):
    if s[i] == "<":
        st.append([0,1])
    elif s[i] == ">":
        st.append([2,1])
    else:
        if st and st[-1][0] == 1:
            st[-1][1] += 1
        else:
            st.append([1,1])
    
    if len(st) < 3:
        continue
    if st[-3][0] == 0 and st[-2][0] == 1 and st[-1][0] == 2:
        st.pop()
        st.pop()
        st.pop()

ans = sum(c for i,c in st)
print(ans) 
            

# n,k = MI()
# h = LI()
# p = LLI(n)

# uf = dsu(n)

# def dis(p,q):
#     return (p[0]-q[0])**2 + (p[1]-q[1])**2


# edge = [set() for i in range(n)]
# for i in range(n):
#     for j in range(n):
#         if h[i] < h[j] and dis(p[i],p[j]) <= k**2:
#             edge[i].add(j)

# ans = 0
# for i in range(n):
#     if edge[i] == set():
#         ans += 1
# print(ans)
0