我不会打
3 个赞
我不会用cout<<a+b<<endl;
3 个赞
endl我都没学过
3 个赞
题面没作要求
2 个赞
我不太会用加法
3 个赞
AC代码
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a+b << endl;
return 0;
}
4 个赞
GDB告诉我cur->nxt->pre = cur;
RE了,是因为cur->nxt
是空指针吗?
3 个赞
这题无视 Problem这个东西
4 个赞
直接printf(“%d”,a+b);
3 个赞
不可以对head
或 tail
进行 merge
或 split
3 个赞
怎么可以这么粗暴地刷解决方案
3 个赞
!!!
3 个赞
但本来这样就解决了呀
3 个赞
感觉你这是个天才
3 个赞
并且t1
和t2
初始不在链表中
3 个赞
难道你是真的天才
3 个赞
感觉调了以后还是RE
#include<bits/stdc++.h>
using namespace std;
const int k = 700;
const int _nk = 1000;
const int _2k = 1400;
struct node;
using np = node*;
struct node {
vector<int>*a;
np pre, nxt;
};
np _Pl;
np _Pr;
queue<np>bin;
int _Cnt = 32;
inline void CreateNewPlace() {
_Pr = (_Pl = (np)(malloc(sizeof(node) * _Cnt))) + _Cnt;
_Cnt <<= 1;
}
inline np newnp() {
if (bin.size()) {
np tmp = bin.front();
bin.pop();
return tmp;
}
if (_Pl == _Pr)CreateNewPlace();
return (_Pl++);
}
inline void delnp(np x) {
bin.push(x);
x->a->clear();
x->a = nullptr;
x->pre = x->nxt = nullptr;
}
inline void checks(np cur);
inline void checkm(np cur);
inline void split(np cur) {
if(cur ->pre ==cur || cur->nxt == cur || cur == nullptr)return;
np tmp = newnp();
int ts = cur->a->size() >> 1;
vector<int> tv(cur->a->begin() + ts, cur->a->end());
tmp->a = &tv;
cur->a->erase(cur->a->begin() + ts, cur->a->end());
tmp->nxt = cur->nxt;
tmp->pre = cur;
tmp->nxt->pre = tmp;
tmp->pre->nxt = cur;
checks(tmp);
checks(cur);
return;
}
inline void merge(np cur, np tmp) {
if(cur ->pre == cur || tmp ->nxt == tmp || cur == tmp)return;
cur->a->insert(cur->a->end(), tmp->a->begin(), tmp->a->end());
cur->nxt = tmp->nxt;
cur->nxt->pre = cur;
delnp(tmp);
checkm(cur);
return;
}
inline void checks(np cur) {
if (cur->a->size() >= _2k)split(cur);
return;
}
inline void checkm(np cur) {
if ((cur->a->size() + cur->nxt->a->size()) < _nk)merge(cur, cur->nxt);
if ((cur->pre->a->size() + cur->a->size()) < _nk)merge(cur->pre, cur);
}
node head, tail;
inline void init() {
head.pre = &head;
head.nxt = &tail;
tail.pre = &head;
tail.nxt = &tail;
}
int main() {
init();
int a, b;
cin >> a >> b;
vector<int>veca(1, a);
vector<int>vecb(1, b);
node t1, t2;
t1.nxt = &t2;
t2.pre = &t1;
t1.pre = &head;
t2.nxt = &tail;
head.nxt = &t1;
tail.pre = &t2;
t1.a = &veca;
t2.a = &vecb;
merge(&t1,&t2);
split(&t1);
cout << *(head.nxt->a->begin()) + *(tail.pre->a->begin());
return 0;
}
3 个赞
此帖子已被社区举报,现已被临时隐藏。
警告一次,不要回老帖
1 个赞