【求助】最后一个点总是TLE

P1795 无穷的序列

我能优化的都优化了(代码很乱请dalao见谅哈),为啥还是TLE QAQ ```cpp #include <algorithm> #include <array> #include <bitset> #include <iostream> #include <cstdio> std::array<int, 1500010> a; std::array<int, 1500010> sortedA; std::bitset<1000000010> series; int main(void) { int max, n, zero; max = 0; zero = 0; a.fill(0); sortedA.fill(0); std::scanf("%d", &n); for (int i = 0; i < n; i++) { std::scanf("%d", &(a.at(i))); sortedA.at(i) = a.at(i); } std::stable_sort(sortedA.begin(), sortedA.begin() + n); max = sortedA.at(n - 1); for (int i = 0; i < max; i++) { series[i] = 1; i += zero; ++zero; } for (int i = 0; i < n; i++) { std::cout << series[a.at(i) - 1] << std::endl; } return 0; } ``` 求dalao指点QAQ
by 聪明的猪 @ 2019-08-03 22:19:05


加上这个 ```cpp #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native") #include <immintrin.h> #include <emmintrin.h> ```
by Del_Your_Heart @ 2019-08-03 22:36:40


相信玄学的力量
by Del_Your_Heart @ 2019-08-03 22:37:01


$NOIP$别用就行
by Del_Your_Heart @ 2019-08-03 22:37:30


我也是,嘤嘤嘤…… ```cpp #include <iostream> #include <cmath> using namespace std; bool check(int a){ int x = (a - 1) * 2; int s = floor(sqrt(x)); return s * (s + 1) == x; } int n, t; int main(){ cin >> n; for (int i = 1;i <= n;i ++){ cin >> t; cout << check(t) << endl; } } ```
by YuJiahe @ 2021-06-11 22:11:09


@[YuJiaheAKIOI](/user/477443) 别用1.5e6的数据别用cin,cout,看我这两份提交记录你就知道为什么了 https://www.luogu.com.cn/record/59155890 https://www.luogu.com.cn/record/59155938
by peiwenjun @ 2021-10-04 23:55:51


感谢大神,本来我也卡在了最后一个点上,一直不知道怎么改,后来看到cin比scanf要慢,改成了标准格式输入输出,果然过了!!!
by Rain_chr @ 2022-03-10 11:17:53


@[peiwenjun](/user/163993) 你的提交记录无权查看
by Rain_chr @ 2022-03-10 11:18:27


@[chenhongrui321](/user/684254) 远古帖子也没必要看了吧/qd,知道就行了
by peiwenjun @ 2022-03-10 12:46:01


@[peiwenjun](/user/163993) 哈哈
by Rain_chr @ 2022-03-10 19:04:53


|