-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
152 lines (146 loc) · 2.93 KB
/
test.cpp
File metadata and controls
152 lines (146 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Don’t cry in a corner, if you want something, mehnat kar, best ban, aur cheen le.
// Boy's Nobody come here to save you have to fight alone with a smile face.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/tree_policy.hpp>
#define M 1000000007
#define ll long long
#define int long long
#define arr vector<int>v(n);
#define END cout<<endl;
#define nn int n;cin >> n;
#define string1 string s;cin >> s;
#define loop(n) for (auto i = 0; i < n; i++)
#define lop(n) for (auto j = 0; j < n; j++)
#define takearr(n) for (auto i = 0; i < n; i++){cin>>v[i];}
#define takestr(n) for(int i=0;i<n;i++){char ch; cin>>ch; s+=ch;}
#define srt sort(v.begin(),v.end());
#define srtr sort(v.rbegin(),v.rend());
#define loophalf(n) for (int i = n / 2 - 1; i < n; i++)
#define lop2(n) for (auto j = 1; j <= n; j++)
#define dgb(...) ;
#define debug(...) ;
#define crndl
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
int sieve[1000005];
int v[1000005];
void sieveOfEratosthenes() {
memset(sieve, 0, sizeof(sieve));
sieve[0] = 0;
sieve[1] = 0;
for (int i = 2; i < 1000005; i++) {
if (sieve[i] != 0) {
continue;
}
for (int j = i; j < 1000005; j += i) {
if (sieve[j] == 0) sieve[j] = i;
}
}
}
string lshift(string s) {
return s.substr(1, s.length() - 1) + s.substr(0, 1);
}
string rshift(string s) {
return s.back() + s.substr(0, s.length() - 1);
}
struct point {
int x, y;
bool operator<(const point &p) {
if (x == p.x) return y < p.y;
else return x < p.x;
}
};
bool isprime(int n) {
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return true;
}
bool cmp(vector<int>&a , vector<int>&b) {
return a < b;
}
int fin(int n) {
return (n * (n + 1)) / 2;
}
int powM(int x , int n) {
x %= M;
if (n == 0) return 1;
else if (n == 1) return x;
int y = powM(x * x , n / 2);
if (n % 2) {
return y * x % M;
}
else {
return y;
}
}
int pow(int x , int n) {
if (n == 0) return 1;
else if (n == 1) return x;
int y = pow(x * x , n / 2);
if (n & 1) {
return y * x;
}
else {
return y;
}
}
int fun(vector<int>&arr1 , vector<int>&arr2) {
auto it = remove_if(arr2.begin(), arr2.end(), [&arr1](int num) {
return find(arr1.begin(), arr1.end(), num) != arr1.end();
});
arr2.erase(it, arr2.end());
return arr2.size();
}
bool allEqual( vector<int>&v) {
for (int i = 1; i < v.size(); i++) {
if (v[i] != v[i - 1]) {
return false;
}
}
return true;
}
int msb(int n) {
for (int i = 32; i > 0; i--) {
if (n & (1LL << i)) {
return i;
}
}
return 0;
}
void solve()
{
int n;
cin >> n;
vector<int>v(n+1);
for (int i = 1; i <= n; i++) {
cin >> v[i];
}
unordered_map<int, int>mp;
for (int i = 1; i <= n; i++) {
mp[v[i]] = i;
}
int sum = 0;
for(auto i:mp){
sum += i.second;
}
cout<<sum<<endl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t-- > 0)
{
debug(testcase, tc);
solve();
crndl;
}
return 0;
}