QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#483641 | #7517. Flying Ship Story | asitshouldbe | WA | 241ms | 3684kb | C++14 | 3.5kb | 2024-07-18 21:50:47 | 2024-07-18 21:50:47 |
Judging History
answer
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <unordered_set>
#include <unordered_map>
//#define x first
//#define y second
#define endl '\n'
#define pi acos(-1.0)
using namespace std;
typedef pair<int, int> PII;
typedef pair<double, int> PDI;
typedef pair<PII, int> PIII;
typedef pair<PII, char> PIIC;
typedef long long LL;
int dx[] = {1, 0, 0, -1, -1, -1, 1, 1}, dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
int mou[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int N = 1e6 + 10, M = 110, mod = 998244353, INF = 0x3f3f3f3f;
const double eps = 1e-8;
int x,y,w,last,t;
struct node
{
int x,y,w;
bool operator<(const node& t)
{
return w>t.w;
}
};
vector<node>v;
void insert(int x,int y,int w)
{
v.push_back({x,y,w});
sort(v.begin(),v.end());
vector<node>t;
int x0,y0,x1,y1,x2,y2,cnt=0;
for(int i=0;i<v.size();i++)
{
if(cnt==0) //全集
{
x0=v[i].x,y0=v[i].y;
t.push_back(v[i]);
cnt=1;
}
else if(cnt==1) //一个十字
{
//if(v[i].x==x0&&v[i].y==y0) continue;
if(v[i].x==t[t.size()-1].x&&v[i].y==t[t.size()-1].y) continue;
t.push_back(v[i]);
if(v[i].x!=x0&&v[i].y!=y0)
{
x1=v[i].x,y1=v[i].y;
cnt=2;
}
else if(v[i].x!=x0) x1=v[i].x,y1=y0,cnt=3;
else if(v[i].y!=y0) y1=v[i].y,x1=x0,cnt=4;
}
else if(cnt==2) //两个格子
{
//if(v[i].x==x1&&v[i].y==y1) continue;
if(v[i].x==t[t.size()-1].x&&v[i].y==t[t.size()-1].y) continue;
t.push_back(v[i]);
cnt=5;
if((v[i].x!=x0&&v[i].y!=y1)&&(v[i].x!=x1&&v[i].y!=y0)) break;
else if(v[i].x!=x0&&v[i].y!=y1) x2=x1,y2=y0;
else if(v[i].x!=x1&&v[i].y!=y0) x2=x0,y2=y1;
}
else if(cnt==3) //一条竖线
{
if(v[i].x==t[t.size()-1].x&&v[i].y==t[t.size()-1].y) continue;
if(v[i].y!=y1)
{
t.push_back(v[i]);
x2=v[i].x,y2=y1;
cnt=5;
}
}
else if(cnt==4) //一条横线
{
if(v[i].x==t[t.size()-1].x&&v[i].y==t[t.size()-1].y) continue;
if(v[i].x!=x1)
{
t.push_back(v[i]);
x2=x1,y2=v[i].y;
cnt=5;
}
}
else if(cnt==5) //一个格子
{
if(v[i].x==t[t.size()-1].x&&v[i].y==t[t.size()-1].y) continue;
if(v[i].x!=x2&&v[i].y!=y2)
{
t.push_back(v[i]);
break;
}
}
}
v=t;
}
int query(int x,int y)
{
for(auto i:v)
if(x!=i.x&&y!=i.y) return i.w;
return 0;
}
void solve()
{
int op;
cin>>op;
if(op==1)
{
cin>>x>>y>>w;
x^=last,y^=last,w^=last;
insert(x,y,w);
}
else
{
cin>>x>>y;
x^=last,y^=last;
last=query(x,y);
cout<<last<<endl;
}
}
int main()
{
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0),cout.precision(10);
// freopen("in.in","r",stdin);
// freopen("test.out","w",stdout);
t=1; cin >> t;
while (t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
5 1 2 3 1 1 4 5 2 2 2 2 2 3 7 2 3 4
output:
2 1 0
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 201ms
memory: 3644kb
input:
1000000 2 370943499 431961772 1 1 1 11995570 2 37566858 838793045 1 11995571 11995569 908148975 2 11995571 11995571 1 1 3 716821068 2 67877937 3 1 11995571 11995571 771898489 2 38381714 99749723 1 915818844 915818847 729541681 2 592361351 915818846 1 783627722 783627722 639375021 2 102203700 8636489...
output:
0 11995570 0 11995570 915818845 783627723 915818845 0 0 915818845 0 783627723 0 904468304 904468304 904468304 915818845 904468304 915818845 904468304 915818845 0 904468304 0 915818845 915818845 0 0 915818845 915818845 0 921710773 0 921710773 998138906 921710773 0 921710773 998138906 0 998138906 0 99...
result:
ok 500000 lines
Test #3:
score: -100
Wrong Answer
time: 241ms
memory: 3684kb
input:
1000000 2 648544745 437316088 1 1 1 221075686 2 802693951 691188141 1 221075687 221075684 1036811136 2 771835961 178451319 1 820061031 820061031 560017372 2 829408420 820061028 1 293604539 293604539 699366423 2 293604539 293604539 1 1 2 610044241 2 50747012 885321059 1 942633132 942633132 603537610 ...
output:
0 221075686 820061030 293604538 0 942633133 942633133 27478144 820061030 820061030 900696946 27478144 942633133 942633133 0 772167494 27478144 891145650 900696946 772167494 891145650 918281274 772167494 772167494 772167494 772167494 772167494 942633133 918281274 891145650 918281274 891145650 8911456...
result:
wrong answer 188th lines differ - expected: '912214041', found: '0'