Submission #64338557
Source Code Expand
Copy
#include <bits/stdc++.h>#define int long long//#define USE_FREOPEN#define MUL_TEST#define FILENAME ""using namespace std;bool nok[400005];int a[400005];void solve() {map<pair<int,int>,int> mp;int n;cin >> n;for (int i = 0; i <= 2 * n; i++) {nok[i] = 0;a[i] = 0;}for (int i = 1; i <= 2 * n; i++) {cin >> a[i];if (a[i] == a[i - 1]) nok[a[i]] = 1;}
#include <bits/stdc++.h> #define int long long //#define USE_FREOPEN #define MUL_TEST #define FILENAME "" using namespace std; bool nok[400005]; int a[400005]; void solve() { map<pair<int,int>,int> mp; int n; cin >> n; for (int i = 0; i <= 2 * n; i++) { nok[i] = 0; a[i] = 0; } for (int i = 1; i <= 2 * n; i++) { cin >> a[i]; if (a[i] == a[i - 1]) nok[a[i]] = 1; } for (int i = 2; i <= 2 * n; i++) { int mx = max(a[i],a[i - 1]),mi = min(a[i],a[i - 1]); if (nok[mx] || nok[mi]) continue; mp[make_pair(mi,mx)]++; } int ans = 0; for (auto it : mp) { if (it.second >= 2) ans++; } cout << ans << '\n'; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef USE_FREOPEN freopen(FILENAME ".in","r",stdin); freopen(FILENAME ".out","w",stdout); #endif int _ = 1; #ifdef MUL_TEST cin >> _; #endif while (_--) solve(); _^=_; return 0^_^0; }
Submission Info
Submission Time | |
---|---|
Task | D - Switch Seats |
User | Hyh12377 |
Language | C++ 20 (gcc 12.2) |
Score | 0 |
Code Size | 971 Byte |
Status | WA |
Exec Time | 310 ms |
Memory | 32044 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt |
All | 00_sample_00.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 02_random_1_00.txt, 02_random_1_01.txt, 02_random_1_02.txt, 02_random_1_03.txt, 02_random_1_04.txt, 03_random_2_00.txt, 03_random_2_01.txt, 03_random_2_02.txt, 04_max_00.txt, 05_corner_00.txt, 05_corner_01.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3600 KB |
01_small_00.txt | WA | 24 ms | 3460 KB |
01_small_01.txt | WA | 25 ms | 3464 KB |
01_small_02.txt | WA | 38 ms | 3540 KB |
01_small_03.txt | WA | 38 ms | 3608 KB |
01_small_04.txt | WA | 38 ms | 3664 KB |
01_small_05.txt | WA | 38 ms | 3464 KB |
01_small_06.txt | WA | 38 ms | 3612 KB |
02_random_1_00.txt | WA | 301 ms | 31912 KB |
02_random_1_01.txt | AC | 306 ms | 31964 KB |
02_random_1_02.txt | WA | 304 ms | 31976 KB |
02_random_1_03.txt | WA | 304 ms | 31980 KB |
02_random_1_04.txt | WA | 310 ms | 32044 KB |
03_random_2_00.txt | AC | 240 ms | 23228 KB |
03_random_2_01.txt | AC | 244 ms | 23312 KB |
03_random_2_02.txt | AC | 235 ms | 23232 KB |
04_max_00.txt | AC | 81 ms | 19628 KB |
05_corner_00.txt | AC | 19 ms | 7044 KB |
05_corner_01.txt | AC | 39 ms | 13288 KB |