解题思路:
我是来吐槽的,同样的代码,一下超时一下正确,服了
注意事项:
参考代码
#include<iostream>
#include<stdio.h>
#include<string>
#include<stdio.h>
#include<vector>
#include<unordered_map>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<list>
#include<set>
#include<algorithm>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
template<typename T> bool mmax(T A, T B) {
return A > B ? true : false;
}
template<typename T> bool mmin(T a, T b) {
return a < b ? true : false;
}
#define IOS std::ios_base::sync_with_stdio(false);std::cin.tie(nullptr);std::cout.tie(nullptr);
inline ll read() {
ll s = 0, w = 0;
char c = getchar();
while (!isdigit(c))w |= (c == '-'), c = getchar();
while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
return w ? -s : s;
}
//ll nextval[1005];//KMP
ll h[2005], f[2605], n, cnt, p, q;
set<ll>ss;
/*inline void get_next(string t) {
int j = 0, k = -1;
nextval[0] = -1;
while (j < t.length()) {
if (k == -1 || t[j] == t[k]) {
j++, k++;
if (t[j] != t[k]) nextval[j] = k;
else nextval[j] = nextval[k];
}
else k = nextval[k];
}
}
inline bool KMP(string s,string t){
get_next(t);
ll i = 0, j = 0,sl=s.length(),tl=t.length();
while (i < sl &&j < tl) {
if (j == -1 || s[i] == t[j])j++, i++;
else j = nextval[j];
}
if (j == tl) return true;
else return false;
}*/
inline void Init() {
for (int i = 0; i <= 2 * n; i++) f[i] = i;
}
ll Find(ll i) { return i == f[i] ? i : f[i] = Find(f[i]); }
inline void merge(ll a, ll b) {
ll fa = Find(a), fb = Find(b);
//if (fa != fb) {
f[fa] = fb;
//}
}
ll a[1000002], b[1000006];
unordered_map<ll, bool>aa;
unordered_map<ll, bool>bb;
int main() {
ll n = read(), m = read(),k=0;
for (int i = 0; i < n; i++) a[i] = read(),aa[a[i]]=true;
ll l1 = read(), r1 = read();
for (int i = l1-1 ; i < r1; i++) b[k++] = a[i];
//cout << k << endl;
memset(a, 0, sizeof(a));
for (int i = 0; i < m; i++) a[i] = read(), bb[a[i]] = true;
ll l2 = read(), r2 = read();
for (int i = l2-1 ; i < r2; i++) b[k++] = a[i];
sort(b, b + k);
for (int i = 0; i < k;i++) {
if (aa[b[i]]) printf("%d ", 1);
else printf("%d ", 2);
}
return 0;
}
:
0.0分
1 人评分
C语言训练-角谷猜想 (C++代码)(3N+1问题)浏览:1850 |
C二级辅导-同因查找 (C语言代码)浏览:626 |
这可能是一个假的冒泡法浏览:1071 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:724 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:624 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:606 |
WU-蓝桥杯算法提高VIP-勾股数 (C++代码)浏览:1685 |
WU-整除问题 (C++代码)浏览:648 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:628 |
a+b浏览:452 |