Submission #62075971
Source Code Expand
Copy
/*Start:End:Time used:「責任を負う人の話は、あなたと話したことがありますよね」「当時の私はまだわからないけど……今は理解できるようになった」「大人としての責務。そして、その延長線上にある、あなたの選択」「それに代表されるアイデアもあります」「だから、先生」「信じられる大人のあなたなら、この歪んだ変形の終点とは、違う結果……そこにつながる選択肢……きっとあなたは見つけることができます」DON'T GET STUCK ON ONE APPROACH!!!*/#include <bits/stdc++.h>//喵内~#define re register//喵内~#define rep(i,a,b) for (re int i = (a);i <= (b); ++i)#define debug(x) cout << #x << '=',print(x),putchar(' ')#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)#define pi pair<int,int>#define mp(a,b) make_pair(a,b)#define int long longtypedef long long ll;
/* Start: End: Time used: 「責任を負う人の話は、あなたと話したことがありますよね」 「当時の私はまだわからないけど……今は理解できるようになった」 「大人としての責務。そして、その延長線上にある、あなたの選択」 「それに代表されるアイデアもあります」 「だから、先生」 「信じられる大人のあなたなら、この歪んだ変形の終点とは、違う結果……そこにつながる選択肢……きっとあなたは見つけることができます」 DON'T GET STUCK ON ONE APPROACH!!! */ #include <bits/stdc++.h>//喵内~ #define re register//喵内~ #define rep(i,a,b) for (re int i = (a);i <= (b); ++i) #define debug(x) cout << #x << '=',print(x),putchar(' ') #define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout) #define pi pair<int,int> #define mp(a,b) make_pair(a,b) #define int long long typedef long long ll; using namespace std;//喵内~ inline ll read(){ ll s = 0,f = 1;char c = getchar(); while (!isdigit(c)){if (c == '-')f = -1;c = getchar();} while (isdigit(c)){s = (s<<3) + (s<<1) + (c ^ 48);c = getchar();} return s * f; }//喵内~ void print(__int128 x){if (x < 0) {putchar('-'),print(-x);return ;}if (x >= 10) print(x / 10);putchar(x % 10 + 48);}//喵内~ const int Mod = 1e9 + 7;//喵内~要填数字哟~ //const int Mod = 998244353;//喵内~要填数字哟~ const ll INF = 0x3f3f3f3f; const int N = 3e5 + 5;//喵内~要填数字哟~ ll qpow(ll x,ll y){ ll res = 1; for (;y;y >>= 1,x = x * x % Mod) if (y & 1) res = res * x % Mod; return res; } //ATTENTION IS ALL YOU NEED int pre[N],pos[2][N]; int a[N],n; signed main(){ n = read(); for (int i = 1;i <= n;++i) a[i] = read(); ll sum = 0,ans = 0; for (int i = 1;i <= n;++i){ int p = pos[0][a[i]]; int p1 = pos[0][a[i] - 1]; int p2 = pos[0][a[i] + 1]; if (p1 > p) sum -= p1 - p; if (p2 > p) sum -= p2 - p; sum -= p; sum += i; // debug(sum),puts(""); pos[1][a[i]] = pos[0][a[i]]; pos[0][a[i]] = i; if (!pre[a[i]]) pre[a[i]] = i; ans += sum; } cout << ans << endl; return 0; }//喵内~ /* What's wrong with my code? 1. 小数据?特殊数据?如 n = 1? 2. 最小值,最大值取多少?是否会溢出? 3. 初始值有没有赋值?有没有建树? 4. 数组大小?是否越界? 5. 思考暴力的时候,考虑是否可能是多个连续段?或者是个数不确定无法暴力? 6. 进行详细的分类讨论? 7. 选择的区间是否可以为空? Trick: 1. 连通 通常带有特殊性质 2. LIS 有另一种求法 3. Brovuka? About implementation skills: 1. 全局变量多用长变量名,而局部变量,临时变量,和函数传递的参数使用短变量名。 2. 大模拟尽量遵循:怎么方便怎么写。 3. 对于一些数据很小的需要维护的量并且需要大量讨论时,可以考虑把数组拆掉换成变量。 4. 写成多个函数。 */
Submission Info
Submission Time | |
---|---|
Task | F - Double Sum 3 |
User | FlamingBlade |
Language | C++ 20 (gcc 12.2) |
Score | 525 |
Code Size | 3174 Byte |
Status | AC |
Exec Time | 15 ms |
Memory | 12988 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 525 / 525 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 02_permutation_00.txt, 02_permutation_01.txt, 02_permutation_02.txt, 02_permutation_03.txt, 02_permutation_04.txt, 02_permutation_05.txt, 02_permutation_06.txt, 02_permutation_07.txt, 02_permutation_08.txt, 02_permutation_09.txt, 02_permutation_10.txt, 02_permutation_11.txt, 03_random_00.txt, 03_random_01.txt, 03_random_02.txt, 03_random_03.txt, 03_random_04.txt, 03_random_05.txt, 03_random_06.txt, 03_random_07.txt, 03_random_08.txt, 03_random_09.txt, 03_random_10.txt, 03_random_11.txt, 03_random_12.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3620 KB |
00_sample_01.txt | AC | 1 ms | 3624 KB |
00_sample_02.txt | AC | 1 ms | 3544 KB |
01_handmade_00.txt | AC | 1 ms | 3544 KB |
01_handmade_01.txt | AC | 8 ms | 5836 KB |
01_handmade_02.txt | AC | 11 ms | 12748 KB |
02_permutation_00.txt | AC | 5 ms | 6340 KB |
02_permutation_01.txt | AC | 6 ms | 7308 KB |
02_permutation_02.txt | AC | 15 ms | 12704 KB |
02_permutation_03.txt | AC | 13 ms | 11560 KB |
02_permutation_04.txt | AC | 14 ms | 12160 KB |
02_permutation_05.txt | AC | 15 ms | 12856 KB |
02_permutation_06.txt | AC | 15 ms | 12908 KB |
02_permutation_07.txt | AC | 14 ms | 12984 KB |
02_permutation_08.txt | AC | 15 ms | 12908 KB |
02_permutation_09.txt | AC | 15 ms | 12784 KB |
02_permutation_10.txt | AC | 11 ms | 12856 KB |
02_permutation_11.txt | AC | 11 ms | 12848 KB |
03_random_00.txt | AC | 3 ms | 5012 KB |
03_random_01.txt | AC | 3 ms | 5296 KB |
03_random_02.txt | AC | 8 ms | 8444 KB |
03_random_03.txt | AC | 3 ms | 5264 KB |
03_random_04.txt | AC | 5 ms | 6624 KB |
03_random_05.txt | AC | 15 ms | 12988 KB |
03_random_06.txt | AC | 15 ms | 12984 KB |
03_random_07.txt | AC | 15 ms | 12860 KB |
03_random_08.txt | AC | 15 ms | 12952 KB |
03_random_09.txt | AC | 15 ms | 12888 KB |
03_random_10.txt | AC | 2 ms | 3928 KB |
03_random_11.txt | AC | 4 ms | 4452 KB |
03_random_12.txt | AC | 3 ms | 4544 KB |