File tree 5 files changed +132
-0
lines changed
solutions/Codeforces/Codeforces Round 981 (Div. 3)
5 files changed +132
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ void solve () {
5
+ int n;
6
+ cin >> n;
7
+ cout << (n % 2 ? " Kosuke" : " Sakurako" ) << " \n " ;
8
+ }
9
+
10
+ int main () {
11
+ ios::sync_with_stdio (false );
12
+ cin.tie (0 );
13
+ cout.tie (0 );
14
+
15
+ int t = 1 ;
16
+ cin >> t;
17
+ while (t--) solve ();
18
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ void solve () {
5
+ int n;
6
+ cin >> n;
7
+ vector<int > a (2 * n);
8
+ long long ans = 0 ;
9
+ for (int i = 0 ; i < n; i++) {
10
+ for (int j = 0 ; j < n; j++) {
11
+ int x;
12
+ cin >> x;
13
+ a[n + i - j] = max (a[n + i - j], -x);
14
+ }
15
+ }
16
+ for (int i = 0 ; i < 2 * n; i++) {
17
+ // cout << a[i] << " ";
18
+ ans += a[i];
19
+ }
20
+ cout << ans << " \n " ;
21
+ }
22
+
23
+ int main () {
24
+ ios::sync_with_stdio (false );
25
+ cin.tie (0 );
26
+ cout.tie (0 );
27
+
28
+ int t = 1 ;
29
+ cin >> t;
30
+ while (t--) solve ();
31
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ void solve () {
5
+ int n;
6
+ cin >> n;
7
+ vector<int > a (n);
8
+ for (auto &i : a) cin >> i;
9
+ int ans = a[0 ] == 0 ;
10
+ long long sum = a[0 ];
11
+ set<int > seen;
12
+ seen.insert (a[0 ]);
13
+ seen.insert (0 );
14
+ for (int i = 1 ; i < n; i++) {
15
+ sum += a[i];
16
+ if (seen.count (sum))
17
+ ans++, sum = 0 , seen.clear (), seen.insert (0 );
18
+ else
19
+ seen.insert (sum);
20
+ };
21
+ cout << ans << " \n " ;
22
+ }
23
+
24
+ int main () {
25
+ ios::sync_with_stdio (false );
26
+ cin.tie (0 );
27
+ cout.tie (0 );
28
+
29
+ int t = 1 ;
30
+ cin >> t;
31
+ while (t--) solve ();
32
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ void solve () {
5
+ int n;
6
+ cin >> n;
7
+ vector<int > a (n);
8
+ for (auto &i : a) {
9
+ cin >> i;
10
+ i--;
11
+ }
12
+
13
+ vector<int > vis (n, false );
14
+ int d = 0 , ans = 0 ;
15
+ for (int i = 0 ; i < n; i++) {
16
+ int j = i;
17
+ while (!vis[j]) {
18
+ vis[j] = true ;
19
+ d++;
20
+ j = a[j];
21
+ }
22
+ ans += max (0 , (d - 1 ) / 2 );
23
+ d = 0 ;
24
+ }
25
+
26
+ cout << ans << " \n " ;
27
+ }
28
+
29
+ int main () {
30
+ ios::sync_with_stdio (false );
31
+ cin.tie (0 );
32
+ cout.tie (0 );
33
+
34
+ int t = 1 ;
35
+ cin >> t;
36
+ while (t--) solve ();
37
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ void solve () {}
5
+
6
+ int main () {
7
+ ios::sync_with_stdio (false );
8
+ cin.tie (0 );
9
+ cout.tie (0 );
10
+
11
+ int t = 1 ;
12
+ cin >> t;
13
+ while (t--) solve ();
14
+ }
You can’t perform that action at this time.
0 commit comments