QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#798335 | #168. Cube Dividing | CarroT1212 | WA | 1ms | 6012kb | C++14 | 1.8kb | 2024-12-04 12:24:29 | 2024-12-04 12:24:30 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define go(xx,yy,zz) for(ll x=xx-1;x<=xx+1;x++)for(ll y=yy-1;y<=yy+1;y++)for(ll z=zz-1;z<=zz+1;z++)
using namespace std; bool MEM;
using ll=long long; using ld=long double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
const int I=1e9;
const ll J=1e18,K=1e6+7,N=3e5+7;
ll n,m,nm,a,b,c,ans;
struct nod {
ll x,y,z;
bool operator == (const nod &b) const { return x==b.x&&y==b.y&&z==b.z; }
bool operator < (const nod &b) const { return x!=b.x?x<b.x:y!=b.y?y<b.y:z<b.z; }
} d[N];
map<nod,ll> mp;
vector<ll> v;
bool chk(ll x,ll y,ll z) { return 0<=x&&x<a&&0<=y&&y<b&&0<=z&&z<c; }
struct dsu {
ll f[N];
void ini(ll n) { iota(f+1,f+n+1,1); }
ll fnd(ll x) { return f[x]==x?x:f[x]=fnd(f[x]); }
void mrg(ll x,ll y) { f[fnd(x)]=fnd(y); }
} D;
void solve(ll o) {
map<pll,vector<nod>> pm;
for (ll i=1;i<=n;i++) pm[o==0?(pll){d[i].x,d[i].y}:o==1?(pll){d[i].x,d[i].z}:(pll){d[i].y,d[i].z}].pb(d[i]);
for (auto vv:pm) {
vector<nod> v=vv.se;
for (ll i=0;i+1<v.size();i++) {
ll x=mp[v[i]],y=mp[v[i+1]];
if (x>n&&y>n) D.mrg(x,y);
}
}
}
void mian() {
scanf("%lld%lld%lld%lld",&a,&b,&c,&n);
for (ll i=1;i<=n;i++) scanf("%lld%lld%lld",&d[i].x,&d[i].y,&d[i].z),mp[d[i]]=i;
nm=m=n;
for (ll i=1;i<=n;i++) {
go(d[i].x,d[i].y,d[i].z) if (chk(x,y,z)) d[++m]={x,y,z};
for (ll x:{0ll,d[i].x,a-1}) for (ll y:{0ll,d[i].y,b-1}) for (ll z:{0ll,d[i].z,c-1}) d[++m]={x,y,z};
}
sort(d+1,d+m+1),m=unique(d+1,d+m+1)-1-d;
for (ll i=1;i<=m;i++) if (!mp[d[i]]) mp[d[i]]=++nm;
D.ini(m);
for (ll o=0;o<3;o++) solve(o);
for (ll i=n+1;i<=m;i++) ans+=D.fnd(i)==i;
cout<<ans;
}
bool ORY; int main() {
// while (1)
// int t; for (scanf("%d",&t);t--;)
mian();
cerr<<"\n"<<abs(&MEM-&ORY)/1048576<<"MB";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6012kb
input:
2 2 2 4 0 0 0 1 1 0 1 0 1 0 1 1
output:
4
result:
ok single line: '4'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 5748kb
input:
3 3 3 1 1 1 1
output:
26
result:
wrong answer 1st lines differ - expected: '1', found: '26'