QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#348591 | #5056. Rooks | rajbunsha# | WA | 0ms | 3804kb | C++14 | 4.5kb | 2024-03-09 19:47:23 | 2024-03-09 19:47:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 1e18
#define endl "\n"
#define sorted(x) sort(x.begin(),x.end())
#define sortedr(x) sort(x.rbegin(),x.rend())
#define sum(x) accumulate(x.begin(),x.end(),0LL)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define maxe(x) *max_element(x.begin(),x.end())
#define mine(x) *min_element(x.begin(),x.end())
#define maxi(x) max_element(x.begin(),x.end())-x.begin()
#define mini(x) min_element(x.begin(),x.end())-x.begin()
#define bits(x) __builtin_clzll(0ll) - __builtin_clzll(x)
#define setbits(x) __builtin_popcountll(x)
#define pb push_back
#define ff first
#define ss second
char nl = '\n';
char sp = ' ';
using vb = vector<bool>;
using vi = vector<int>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using si = set<int>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using mii = map<int, int>;
using pqi = priority_queue<int>;
using pqig = priority_queue<int, vi, greater<int>>;
using pqpii = priority_queue<pii>;
using vs = vector<string>;
#define tp3(T) tuple<T,T,T>
#define tp4(T) tuple<T,T,T,T>
#define sort_and_unique(a) sort(all(a));(a).resize(unique(all(a))-(a).begin())
#define outrange(x,min,max) ((x)<(min) || (x)>(max))
int _start_time;
#define nano (chrono::system_clock::now().time_since_epoch().count())
#define reset_timer _start_time=nano
#define chime cout<<((nano-_start_time)/1e9)<<endl
#define init_rng mt19937 rng(nano)
#define randint(a,b) ((a)+rng()%((b)-(a)+1))
#ifndef ONLINE_JUDGE
#define debug(x) (cout<<(#x)<<':'<<(x)<<'\n')
#else
#define debug(x)
#endif
void yesno(bool a) {
cout << (a ? "Yes\n" : "No\n");
}
template<typename L, typename R>
ostream& operator<<(ostream& out, const pair<L, R>& p) {
out << '(' << p.first << ',' << p.second << ')';
return out;
}
template<typename T1, typename T2, typename T3>
ostream& operator<<(ostream& out, const tuple<T1, T2, T3>& tp) {
auto &[t1, t2, t3] = tp;
out << '(' << t1 << ',' << t2 << ',' << t3 << ')';
return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
for (auto &i : v) out << i << ' ';
out << nl;
return out;
}
template<typename T>
ostream& operator<<(ostream& out, const set<T>& v) {
for (auto &i : v) out << i << ' ';
out << nl;
return out;
}
template<typename T>
ostream& operator<<(ostream& out, const unordered_set<T>& v) {
for (auto &i : v) out << i << ' ';
out << nl;
return out;
}
template<typename K, typename V>
ostream& operator<<(ostream& out, const map<K, V>& m) {
out << '[';
for (auto &[k, v] : m) {
out << k << ':' << v << sp;
}
out << "]\n";
return out;
}
template<typename K, typename V>
ostream& operator<<(ostream& out, const unordered_map<K, V>& m) {
out << '[';
for (auto &[k, v] : m) {
out << k << ':' << v << sp;
}
out << "]\n";
return out;
}
#define mod 1000000007
void solve()
{
int n1,n2,k=0,ans=0;
cin>>n1>>n2;
map<int,vector<tp3(int)>> m,my;
vector<vi> occ(2,vi(max(n1,n2)));
for(int i=0;i<n1;i++)
{
int x,y;
cin>>x>>y;
m[x].pb({y,i,0});
my[y].pb({x,i,0});
}
for(int i=0;i<n2;i++)
{
int x,y;
cin>>x>>y;
m[x].pb({y,i,1});
my[y].pb({x,i,1});
}
for(auto &[i,j]: m)
{
sort(all(j));
for(int k=0;k<j.size()-1;k++)
{
auto [pos,ind,grp] = j[k];
auto [pos2,ind2,grp2] = j[k+1];
if(grp != grp2)
{
occ[grp][ind] = 1;
occ[grp2][ind2] = 1;
}
}
}
for(auto &[i,j]: my)
{
sort(all(j));
for(int k=0;k<j.size()-1;k++)
{
auto [pos,ind,grp] = j[k];
auto [pos2,ind2,grp2] = j[k+1];
if(grp != grp2)
{
occ[grp][ind] = 1;
occ[grp2][ind2] = 1;
}
}
}
// cout<<m;
// cout<<occ;
for(int i=0;i<n1;i++)
{
cout<<occ[0][i]<<sp;
}
cout<<nl;
for(int i=0;i<n2;i++)
{
cout<<occ[1][i]<<sp;
}
cout<<nl;
}
signed main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int test=1;
// cin>>test;
while(test--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3804kb
input:
3 2 0 0 0 1 1 0 0 -1 -1 0
output:
1 0 0 1 1
result:
wrong answer 1st lines differ - expected: '100', found: '1 0 0 '