Submission #47772838


Source Code Expand

/*
[templates]: 
duipai
spjdp
compre
addhis
floor_sum
treedfs
matrix
network_flow
polynomial
lca
bitset
valuesgt
fenwick
erbitree
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//use ll instead of int.
#define f(i, a, b) for(int i = (a); i <= (b); i++)
#define cl(i, n) i.clear(),i.resize(n);
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 1e9;
//#define cerr if(false)cerr
//#define freopen if(false)freopen
mt19937 rng(time(0)); 
int rnd(int l, int r) {return rng() % (r-l+1) + l; }
#define watch(x) cerr  << (#x) << ' '<<'i'<<'s'<<' ' << x << endl
void pofe(int number, int bitnum) {
    string s; f(i, 0, bitnum) {s += char(number & 1) + '0'; number >>= 1; } 
    reverse(s.begin(), s.end()); cerr << s << endl; 
    return;
}
template <typename TYP> void cmax(TYP &x, TYP y) {if(x < y) x = y;}
template <typename TYP> void cmin(TYP &x, TYP y) {if(x > y) x = y;}
//调不出来给我对拍!
//use std::array.
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen();
    //freopen();
    //time_t start = clock();
    //think twice,code once.
    //think once,debug forever.
    int n; cin >> n; 
    int ans = 0; int cur = 0; 
    f(i, 1, n - 1) {
        char ch; cin >> ch; 
        if(ch == '<') {
            ans += cur * (cur + 1) / 2; 
            cur = 0; 
        }
        else {
            cur ++; 
        }
    }
    ans += cur * (cur + 1) / 2; 
    cout << ans << endl; 
    //time_t finish = clock();
    //cout << "time used:" << (finish-start) * 1.0 / CLOCKS_PER_SEC <<"s"<< endl;
    return 0;
}

Submission Info

Submission Time
Task A - <Inversion>
User Zeardoe
Language C++ 23 (gcc 12.2)
Score 300
Code Size 1812 Byte
Status AC
Exec Time 5 ms
Memory 3764 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 23
Set Name Test Cases
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 1 ms 3640 KiB
00-sample-002.txt AC 1 ms 3608 KiB
00-sample-003.txt AC 1 ms 3604 KiB
00-sample-004.txt AC 1 ms 3756 KiB
01-001.txt AC 1 ms 3612 KiB
01-002.txt AC 1 ms 3612 KiB
01-003.txt AC 1 ms 3552 KiB
01-004.txt AC 2 ms 3564 KiB
01-005.txt AC 5 ms 3632 KiB
01-006.txt AC 1 ms 3500 KiB
01-007.txt AC 4 ms 3608 KiB
01-008.txt AC 5 ms 3568 KiB
01-009.txt AC 4 ms 3640 KiB
01-010.txt AC 3 ms 3640 KiB
01-011.txt AC 3 ms 3612 KiB
01-012.txt AC 3 ms 3564 KiB
01-013.txt AC 3 ms 3764 KiB
01-014.txt AC 3 ms 3764 KiB
01-015.txt AC 3 ms 3636 KiB
01-016.txt AC 3 ms 3616 KiB
01-017.txt AC 3 ms 3640 KiB
01-018.txt AC 3 ms 3680 KiB
01-019.txt AC 3 ms 3556 KiB