27 条题解
-
0fwkthhm LV 8 @ 2017-08-22 21:37:20
#include<bits/stdc++.h> using namespace std; struct MyStruct { int lx, ly, rx, ry; }; deque<MyStruct>q; class MyClass { public: void open() {//TO DO:读进来的数据入队。 cin >> a.lx >> a.ly >> a.rx >> a.ry; q.push_front(a); } void click() {//TO DO:从队首向后找第一个合适的,移到队首去。 int x, y; cin >> x >> y; for (int i=0; i <q.size(); i++) { if ((q.begin()+i)->lx <= x&&(q.begin() + i)->ly <= y&&(q.begin() + i)->rx >= x&&(q.begin() + i)->ry >= y) { a = q.at(i); q.erase(q.begin()+i); q.push_front(a); break; } } } void _close() {//TO DO:从队首开始找到第一个合适的,删掉 int x, y; cin >> x >> y; for(int i=0;i<q.size();i++) if ((q.begin() + i)->lx <= x&&(q.begin() + i)->ly <= y&&(q.begin() + i)->rx >= x&&(q.begin() + i)->ry >= y) { q.erase(q.begin() + i); break; } } void move() {//TO DO:还是从队首开始找第一个合适的,4个坐标分别加上ab。 int x, y, tx, ty; cin >> x >> y >> tx >> ty; for(int i=0;i<q.size();i++) if ((q.begin() + i)->lx <= x&&(q.begin() + i)->ly <= y&&(q.begin() + i)->rx >= x&&(q.begin() + i)->ry >= y) { q.at(i).lx += tx; q.at(i).ly += ty; q.at(i).rx += tx; q.at(i).ry += ty; break; } } private: MyStruct a; }frog; int n; string ans; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { cin >> ans; if (ans == "Open") frog.open(); else if (ans == "Close") frog._close(); else if (ans == "Move") frog.move(); else frog.click(); } if (q.empty() == true) cout << "Nothing"; else cout << q.begin()->lx << " " << q.begin()->ly << " " << q.begin()->rx << " " << q.begin()->ry; return 0; }
n<100的数据,队列+暴力(其实队列都不一定需要,怎么跑都能对)ps:脑子不好写的迭代器指向,请忽略。
-
02017-07-17 23:11:56@
STL大法好
#include<iostream> #include<deque> using namespace std; typedef struct Win{ int leftX; int leftY; int rightX; int rightY; }Win; deque<Win>windows; int findWin(){ int touchX,touchY; cin>>touchX>>touchY; for(int i=windows.size()-1;i>=0;i--){ if(windows[i].leftX<=touchX&&windows[i].leftY<=touchY &&windows[i].rightX>=touchX&&windows[i].rightY>=touchY){ return i; } } return -1; } void Open(){ auto temp=new Win; cin>>temp->leftX>>temp->leftY>>temp->rightX>>temp->rightY; windows.push_back(*temp); } void Click(){ auto index=findWin(); if(index!=-1){ auto temp=windows[index]; windows.erase(windows.begin()+index); windows.push_back(temp); } } void Move(){ int moveX,moveY; auto index=findWin(); cin>>moveX>>moveY; if(index!=-1){ auto temp=windows[index]; temp.leftX+=moveX; temp.leftY+=moveY; temp.rightX+=moveX; temp.rightY+=moveY; windows.erase(windows.begin()+index); windows.push_back(temp); } } void Close(){ auto index=findWin(); if(index!=-1){ windows.erase(windows.begin()+index); } } int main(void){ int n; cin>>n; string order; for(int i=0;i<n;i++){ cin>>order; if(order=="Open"){ Open(); } else if(order=="Click"){ Click(); } else if(order=="Move"){ Move(); } else{ Close(); } } if(windows.empty()){ cout<<"Nothing"<<endl; } else{ cout<<windows.back().leftX<<' '<<windows.back().leftY<<' ' <<windows.back().rightX<<' '<<windows.back().rightY<<endl; } }
-
02016-07-22 17:32:28@
program computer;
var n,p,i,j,k,tail,t,x,y,a,b:longint;
s:string;
d,x1,y1,x2,y2:array[0..10000] of longint;
v:array[0..10000] of boolean;
begin
readln(n);
fillchar(v,sizeof(v),true);
for p:=1 to n do
begin
readln(s);
if pos('Open',s)=1 then
begin
inc(tail);
s:=copy(s,6,length(s));
t:=pos(' ',s);val( copy(s,1,t-1),x1[tail] );
s:=copy(s,t+1,length(s));
t:=pos(' ',s);val(copy(s,1,t-1),y1[tail]);
s:=copy(s,t+1,length(s));
t:=pos(' ',s);val(copy(s,1,t-1),x2[tail]);
s:=copy(s,t+1,length(s));
val(s,y2[tail]);
end;if pos('Click',s)=1 then
begin
s:=copy(s,7,length(s));
t:=pos(' ',s);val(copy(s,1,t-1),x);
s:=copy(s,t+1,length(s));
val(s,y);
for j:=tail downto 1 do
if v[j] then
if (x1[j]<=x) and (y1[j]<=y) and (x2[j]>=x) and (y2[j]>=y) then
begin
v[j]:=false;
inc(tail);
x1[tail]:=x1[j];x2[tail]:=x2[j];y1[tail]:=y1[j];y2[tail]:=y2[j];
break;
end;
end;
if pos('Clos',s)=1 then
begin
s:=copy(s,7,length(s));
t:=pos(' ',s);val(copy(s,1,t-1),x);
s:=copy(s,t+1,length(s));
val(s,y);
for j:=tail downto 1 do
if v[j] then
if (x1[j]<=x) and (y1[j]<=y) and (x2[j]>=x) and (y2[j]>=y) then
begin
v[j]:=false;
break;
end;
end;
if pos('Move',s)=1 then
begin
s:=copy(s,6,length(s));
t:=pos(' ',s);val( copy(s,1,t-1),x );
s:=copy(s,t+1,length(s));
t:=pos(' ',s);val(copy(s,1,t-1),y);
s:=copy(s,t+1,length(s));
t:=pos(' ',s);val(copy(s,1,t-1),a);
s:=copy(s,t+1,length(s));
val(s,b);
for j:=tail downto 1 do
if v[j] then
if (x1[j]<=x) and (y1[j]<=y) and (x2[j]>=x) and (y2[j]>=y) then
begin
v[j]:=false;
inc(tail);
x1[tail]:=x1[j]+a;x2[tail]:=x2[j]+a;y1[tail]:=y1[j]+b;y2[tail]:=y2[j]+b;
break;
end;
end;
end;
for i:=tail downto 1 do
if v[i] then
begin
writeln(x1[i],' ',y1[i],' ',x2[i],' ',y2[i]);
halt;
end;
writeln('Nothing');
end. -
02016-02-08 22:09:33@
我去,我看题上写的是"Nothing;"我就打的是printf("Nothing;\n");
结果尼玛是Nothing没有分号啊啊啊啊啊!!!F -
02013-10-18 20:54:24@
负数点竟然错了,怎么改啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
-
02009-09-04 08:36:58@
n才100啊,什么算法都不要,直接模拟。 秒杀!!
struct windows
{
int NO,lfx,lfy,rtx,rty;
};
windows win[101];编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms -
02009-08-15 18:57:39@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms
终于秒杀了 耗费了我很多的时间
还有第8 个点 输入有负数 小心 -
02009-06-30 18:54:37@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms
老老实实模拟即可。。。 -
02009-06-27 10:57:08@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案错误...程序输出比正确答案长
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Unaccepted 有效得分:90 有效耗时:0ms
???
第二组数据是什么??? -
02009-04-06 10:50:52@
对不起,您提交的代码中包含非法字符串 Close
这个窘.. -
02009-02-21 15:58:55@
过了若干次...才发现要输出'Nothing'.....
-
02009-01-27 22:24:36@
对不起,您提交的代码中包含非法字符串 Close
真猥琐。。。
∽∽∽∽∽∽∽∽∽∽∽∽∽∽华丽的分割线∽∽∽∽∽∽∽∽∽∽∽∽∽∽∽∽
Accepted 有效得分:100 有效耗时:0ms
改成 clos ……
-
02008-10-10 20:02:25@
begin
readln(n);len:=0;
for i:=1 to n do
begin
read(ch);
flag:=false;
st:='';
while (not eoln)and(not flag) do
begin
st:=st+ch;
if st='Open ' then open;
if st='Click ' then click;
if st='Move ' then move;
if st='Clos' then cl;
read(ch);
end;
readln;
end;
if len=0 then writeln('Nothing')
else writeln(a[1].x1,' ',a[1].y1,' ',a[1].x2,' ',a[1].y2);
end.一次AC
部分代码 -
02008-08-30 12:23:48@
一遍过,,好爽啊
用栈模拟
类似插入排序的方法模拟换位子 -
02008-08-21 16:20:46@
对不起,您提交的代码中包含非法字符串 Close
真猥琐。。。
∽∽∽∽∽∽∽∽∽∽∽∽∽∽华丽的分割线∽∽∽∽∽∽∽∽∽∽∽∽∽∽∽∽
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms -
02008-08-21 15:55:57@
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted
accepted -
02008-08-11 11:40:46@
close····
-
02007-08-13 21:22:25@
AC=模拟+第8个数据的cheat
-
02007-08-11 21:38:51@
吐血夸张题目.又是烦..
-
02007-07-31 16:14:18@
真的是,提交时说有“close”不行,弄得我要多打几个字