# Tarjan Stack wala

Wed Sep 06 2023 13:46:08 GMT+0000 (Coordinated Universal Time)

Saved by @psisodiyaparek #c++

```#include <iostream>
#include <set>
#include <algorithm>
#include <math.h>
#include <vector>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
// #include<bits/stdc++.h>
using namespace std;
#define forn(i, a, n) for (int i = a; i < n; i++)
#define MAXN 1000000
#define MOD 1000000007
#define int long long
#define tc    \
int t;    \
cin >> t; \
while (t--)
#define TC size(arr) / size(arr[0])
#define mp make_pair
#define Krishna cin.tie(NULL);

vector<vector<int>> graph;
int tot = 0;

void findComponent(int u, vector<int> &disc, vector<int> &lowLink, stack<int> &stk, vector<bool> &stkItem)
{
static int time = 0;
stk.push(u);
stkItem[u] = true;

for (auto x : graph[u])
{
{
if (disc[x] == -1)
{
}
else if (stkItem[x])
}
}
int poppedItem = 0;

{
int co = 0;

while (stk.top() != u)
{
poppedItem = stk.top();
co++;
stkItem[poppedItem] = false;
stk.pop();
}
poppedItem = stk.top();
co++;
stkItem[poppedItem] = false;
stk.pop();

if (co > 1)
{
tot += co;
}
}
}

void strongConComponent(vector<vector<int>> &graph)
{
int v = graph.size();
vector<bool> stkItem(v, false);
stack<int> stk;

for (int i = 0; i < v; i++)
if (disc[i] == -1)
}

void solve()
{

tot = 0;
int n;
cin >> n;
graph = vector<vector<int>>(n);
forn(i, 0, n)
{
char x;
cin >> x;
if (x == '<')
{
graph[(i + 1) % n].push_back(i);
}
else if (x == '>')
{
graph[i].push_back((i + 1) % n);
}
else
{
graph[i].push_back((i + 1) % n);
graph[(i + 1) % n].push_back(i);
}
}

strongConComponent(graph);
cout << tot << endl;
}
int32_t main()
{