Skip to content

Commit ccb77b9

Browse files
committed
.
1 parent 09cfc8f commit ccb77b9

14 files changed

+690
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"A. Spy Detected!","group":"Codeforces - Codeforces Round #713 (Div. 3)","url":"https://codeforces.com/contest/1512/problem/0","interactive":false,"memoryLimit":256,"timeLimit":2000,"tests":[{"id":1618065345033,"input":"4\n4\n11 13 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10","output":"2\n1\n5\n3"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ASpyDetected"}},"batch":{"id":"03c92eb7-2cc0-4a8e-87c4-7ebd85e9aaf4","size":1},"srcPath":"c:\\Users\\Dhruv\\myGithub\\Competitive-Programming\\CodeForces\\713 Div3\\A_Spy_Detected_.cpp"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"B. Almost Rectangle","group":"Codeforces - Codeforces Round #713 (Div. 3)","url":"https://codeforces.com/contest/1512/problem/B","interactive":false,"memoryLimit":256,"timeLimit":2000,"tests":[{"input":"6\n4\n..*.\n....\n*...\n....\n2\n*.\n.*\n2\n.*\n.*\n3\n*.*\n...\n...\n5\n.....\n..*..\n.....\n.*...\n.....\n4\n....\n....\n*...\n*...\n","output":"*.*.\n....\n*.*.\n....\n**\n**\n**\n**\n*.*\n*.*\n...\n.....\n.**..\n.....\n.**..\n.....\n....\n....\n**..\n**..\n","id":1618065752479}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"BAlmostRectangle"}},"batch":{"id":"6459cd55-e227-42fe-830f-b253aa6a4ee5","size":1},"srcPath":"c:\\Users\\Dhruv\\myGithub\\Competitive-Programming\\CodeForces\\713 Div3\\B_Almost_Rectangle.cpp"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"C. A-B Palindrome","group":"Codeforces - Codeforces Round #713 (Div. 3)","url":"https://codeforces.com/contest/1512/problem/C","interactive":false,"memoryLimit":256,"timeLimit":2000,"tests":[{"input":"9\n4 4\n01?????0\n3 3\n??????\n1 0\n?\n2 2\n0101\n2 2\n01?0\n0 1\n0\n0 3\n1?1\n2 2\n?00?\n4 3\n??010?0\n","output":"01011010\n-1\n0\n-1\n0110\n-1\n111\n1001\n0101010\n","id":1618069686552}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"CABPalindrome"}},"batch":{"id":"454d2e66-390f-45f0-8d0f-dedb151617b1","size":1},"srcPath":"c:\\Users\\Dhruv\\myGithub\\Competitive-Programming\\CodeForces\\713 Div3\\C_A_B_Palindrome.cpp"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"D. Corrupted Array","group":"Codeforces - Codeforces Round #713 (Div. 3)","url":"https://codeforces.com/contest/1512/problem/D","interactive":false,"memoryLimit":256,"timeLimit":2000,"tests":[{"id":1618068210967,"input":"4\n3\n2 3 7 12 2\n4\n9 1 7 1 6 5\n5\n18 2 2 3 2 9 2\n3\n2 6 9 2 1","output":"2 3 7\n-1\n2 2 2 3 9\n1 2 6"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"DCorruptedArray"}},"batch":{"id":"2b930d9f-0120-4163-b754-639b85b6338a","size":1},"srcPath":"c:\\Users\\Dhruv\\myGithub\\Competitive-Programming\\CodeForces\\713 Div3\\D_Corrupted_Array.cpp"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"E. Permutation by Sum","group":"Codeforces - Codeforces Round #713 (Div. 3)","url":"https://codeforces.com/contest/1512/problem/E","interactive":false,"memoryLimit":256,"timeLimit":2000,"tests":[{"input":"5\n5 2 3 5\n5 3 4 1\n3 1 2 4\n2 2 2 2\n2 1 1 3\n","output":"1 2 3 4 5\n-1\n1 3 2\n1 2\n-1\n","id":1618070845206}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"EPermutationBySum"}},"batch":{"id":"fe8cf8d3-41df-4a92-975c-82a466559689","size":1},"srcPath":"c:\\Users\\Dhruv\\myGithub\\Competitive-Programming\\CodeForces\\713 Div3\\E_Permutation_by_Sum.cpp"}
98.8 KB
Binary file not shown.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
2+
//------------------------------------------------------------------------------
3+
#include <iostream>
4+
#include <vector>
5+
// #include <bits/stdc++.h>
6+
// #include <cmath>
7+
// #include <algorithm>
8+
// #include <unordered_map>
9+
#include <map>
10+
// #include <set>
11+
// #include <unordered_set>
12+
//------------------------------------------------------------------------------
13+
using namespace std;
14+
//------------------------------------------------------------------------------
15+
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
16+
#define v(Type) vector<Type>
17+
#define w(T) \
18+
int T; \
19+
cin >> T; \
20+
while (T--)
21+
#define int long long int
22+
#define mod 1000000007ll
23+
#define endl "\n"
24+
//------------------------------------------------------------------------------
25+
// Any fucntion can be called using Math.function_name();
26+
//------------------------------------------------------------------------------
27+
class Math
28+
{
29+
public:
30+
//Returns gcd of two numbers
31+
int gcd(int a, int b)
32+
{
33+
return (a % b == 0) ? b : gcd(b, a % b);
34+
}
35+
36+
//Returns lcm of two numbers
37+
int lcm(int a, int b)
38+
{
39+
return a * (b / gcd(a, b));
40+
}
41+
42+
// Returns flag array isPrime
43+
// isPrime[i] = true (if i is Prime)
44+
// isPrime[i] = false (if i is not Prime)
45+
vector<bool> *seiveOfEratosthenes(const int N)
46+
{
47+
vector<bool> *isPrime = new vector<bool>(N + 1, true);
48+
(*isPrime)[0] = (*isPrime)[1] = false;
49+
for (int i = 2; i * i <= N; ++i)
50+
if ((*isPrime)[i])
51+
for (int j = i * i; j <= N; j += i)
52+
(*isPrime)[j] = false;
53+
54+
return isPrime;
55+
}
56+
57+
//Returns (x ^ n)
58+
int pow(const int &x, int n)
59+
{
60+
if (n == 0)
61+
return 1;
62+
int h = pow(x, n / 2);
63+
return (n & 1) ? h * h * x : h * h;
64+
}
65+
66+
//Returns (x ^ n) % M
67+
int pow(const int &x, int n, const int &M)
68+
{
69+
if (n == 0)
70+
return 1;
71+
int h = pow(x, n / 2) % M;
72+
return (n & 1) ? (h * h * x) % M : (h * h) % M;
73+
}
74+
75+
//Returns all Primes <= N
76+
vector<int> *primesUptoN(const int N)
77+
{
78+
vector<bool> *isPrime = seiveOfEratosthenes(N);
79+
vector<int> *Primes = new vector<int>;
80+
if (2 <= N)
81+
(*Primes).push_back(2);
82+
for (int i = 3; i <= N; i += 2)
83+
if ((*isPrime)[i])
84+
(*Primes).push_back(i);
85+
return Primes;
86+
}
87+
88+
} Math;
89+
//------------------------------------------------------------------------------
90+
void solve()
91+
{
92+
int ans = 0;
93+
int n;
94+
cin >> n;
95+
v(int) A(n);
96+
for (int i = 0; i < n; i++)
97+
cin >> A[i];
98+
map<int, int> mp;
99+
for (int i = 0; i < n; i++)
100+
mp[A[i]]++;
101+
for (auto x : mp)
102+
if (x.second == 1)
103+
ans = x.first;
104+
int i = 0;
105+
while (i < n and A[i] != ans)
106+
i++;
107+
cout << i + 1 << endl;
108+
}
109+
//------------------------------------------------------------------------------
110+
int32_t main()
111+
{
112+
FastIO;
113+
114+
w(T)
115+
solve();
116+
117+
return 0;
118+
}
119+
//------------------------------------------------------------------------------
63.8 KB
Binary file not shown.
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
2+
//------------------------------------------------------------------------------
3+
#include <iostream>
4+
#include <vector>
5+
// #include <bits/stdc++.h>
6+
// #include <cmath>
7+
// #include <algorithm>
8+
// #include <unordered_map>
9+
// #include <map>
10+
// #include <set>
11+
// #include <unordered_set>
12+
//------------------------------------------------------------------------------
13+
using namespace std;
14+
//------------------------------------------------------------------------------
15+
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
16+
#define v(Type) vector<Type>
17+
#define w(T) \
18+
int T; \
19+
cin >> T; \
20+
while (T--)
21+
#define int long long int
22+
#define mod 1000000007ll
23+
#define endl "\n"
24+
//------------------------------------------------------------------------------
25+
// Any fucntion can be called using Math.function_name();
26+
//------------------------------------------------------------------------------
27+
class Math
28+
{
29+
public:
30+
//Returns gcd of two numbers
31+
int gcd(int a, int b)
32+
{
33+
return (a % b == 0) ? b : gcd(b, a % b);
34+
}
35+
36+
//Returns lcm of two numbers
37+
int lcm(int a, int b)
38+
{
39+
return a * (b / gcd(a, b));
40+
}
41+
42+
// Returns flag array isPrime
43+
// isPrime[i] = true (if i is Prime)
44+
// isPrime[i] = false (if i is not Prime)
45+
vector<bool> *seiveOfEratosthenes(const int N)
46+
{
47+
vector<bool> *isPrime = new vector<bool>(N + 1, true);
48+
(*isPrime)[0] = (*isPrime)[1] = false;
49+
for (int i = 2; i * i <= N; ++i)
50+
if ((*isPrime)[i])
51+
for (int j = i * i; j <= N; j += i)
52+
(*isPrime)[j] = false;
53+
54+
return isPrime;
55+
}
56+
57+
//Returns (x ^ n)
58+
int pow(const int &x, int n)
59+
{
60+
if (n == 0)
61+
return 1;
62+
int h = pow(x, n / 2);
63+
return (n & 1) ? h * h * x : h * h;
64+
}
65+
66+
//Returns (x ^ n) % M
67+
int pow(const int &x, int n, const int &M)
68+
{
69+
if (n == 0)
70+
return 1;
71+
int h = pow(x, n / 2) % M;
72+
return (n & 1) ? (h * h * x) % M : (h * h) % M;
73+
}
74+
75+
//Returns all Primes <= N
76+
vector<int> *primesUptoN(const int N)
77+
{
78+
vector<bool> *isPrime = seiveOfEratosthenes(N);
79+
vector<int> *Primes = new vector<int>;
80+
if (2 <= N)
81+
(*Primes).push_back(2);
82+
for (int i = 3; i <= N; i += 2)
83+
if ((*isPrime)[i])
84+
(*Primes).push_back(i);
85+
return Primes;
86+
}
87+
88+
} Math;
89+
//------------------------------------------------------------------------------
90+
void solve()
91+
{
92+
int n;
93+
cin >> n;
94+
v(string) A(n);
95+
for (int i = 0; i < n; i++)
96+
cin >> A[i];
97+
int x1 = -1, y1 = -1;
98+
int x2 = -1, y2 = -1;
99+
int c = 0;
100+
for (int i = 0; i < n; i++)
101+
for (int j = 0; j < n; j++)
102+
if (A[i][j] == '*')
103+
{
104+
if (c == 0)
105+
x1 = i, y1 = j;
106+
else if (c == 1)
107+
x2 = i, y2 = j;
108+
c++;
109+
}
110+
111+
//Same row
112+
int ansy = 0, ansx = 0;
113+
if (y1 == y2)
114+
{
115+
if (y1 == 0)
116+
ansy++;
117+
A[x1][ansy] = '*';
118+
A[x2][ansy] = '*';
119+
}
120+
// Same col
121+
else if (x1 == x2)
122+
{
123+
if (x1 == 0)
124+
ansx++;
125+
A[ansx][y1] = '*';
126+
A[ansx][y2] = '*';
127+
}
128+
else
129+
{
130+
A[x1][y2] = '*';
131+
A[x2][y1] = '*';
132+
}
133+
for (int i = 0; i < n; i++)
134+
cout << A[i] << endl;
135+
}
136+
//------------------------------------------------------------------------------
137+
int32_t main()
138+
{
139+
FastIO;
140+
141+
w(T)
142+
solve();
143+
144+
return 0;
145+
}
146+
//------------------------------------------------------------------------------
48.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)