Please sign in first.
Submission #12534981
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using ul=unsigned long long;
int s[500],t[500],tmp[500][500],S[500],T[500],n,bit=-1,IN;
ul ans[500][500],u[500],v[500];
void ng(){
cout<<-1;
exit(0);
}
struct P{int va,idx,ve,ne,al;};
bool operator <(const P&a,const P&b){return a.va<b.va;};
priority_queue<P>que;
#define REP(i) for(int i=0;i<n;i++)
#define U ((u[i]>>bit)&1)
#define V ((v[j]>>bit)&1)
#define F(va) {\
if(!~tmp[i][j]){\
ans[i][j]+=((ul)1<<bit)*(tmp[i][j]=va);\
if(++S[i]<n&&IN)que.push({S[i],i,'S',s[i],1});\
if(++T[j]<n&&IN)que.push({T[j],j,'T',t[j],1});\
}\
}
void AL(){
int koushin=1;
while(koushin--){
REP(i)
if(s[i]==U){
bool f=0;
REP(j)f|=tmp[i][j]==s[i];
if(f)REP(j){koushin|=tmp[i][j]<0;F(s[i]^1);}
}
REP(j)
if(t[j]==V){
bool f=0;
REP(i)f|=tmp[i][j]==t[j];
if(f)REP(i){koushin|=tmp[i][j]<0;F(t[j]^1);}
}
}
}
int main(){
cin>>n;
REP(i)cin>>s[i];
REP(i)cin>>t[i];
REP(i)cin>>u[i];
REP(i)cin>>v[i];
while(++bit<64){
memset(tmp,-1,sizeof(tmp));
memset(S,0,sizeof(S));
memset(T,0,sizeof(T));
IN=0;
REP(i)if(s[i]^U)REP(j)F(s[i]^1);
REP(j)if(t[j]^V)REP(i)F(t[j]^1);
REP(i)REP(j)if(s[i]==U&&U==t[j]&&t[j]==V)F(s[i]);
AL();
IN=1;
REP(i)if(S[i]<n)que.push({S[i],i,'S',s[i],1});
REP(j)if(T[j]<n)que.push({T[j],j,'T',t[j],1});
while(que.size()){
P p=que.top();que.pop();
if(p.ve=='S'){
int i=p.idx;
if(p.va<S[i])continue;
REP(j)
if(!~tmp[i][j]){
F(p.ne);
p.ne^=p.al;p.al=0;
}
AL();
}
else{
int j=p.idx;
if(p.va<T[j])continue;
REP(i)
if(!~tmp[i][j]){
F(p.ne);
p.ne^=p.al;p.al=0;
}
AL();
}
}
}
REP(i){
ul A=ans[i][0];
REP(j)
if(s[i])A|=ans[i][j];
else A&=ans[i][j];
if(A!=u[i])ng();
}
REP(j){
ul A=ans[0][j];
REP(i)
if(t[j])A|=ans[i][j];
else A&=ans[i][j];
if(A!=v[j])ng();
}
REP(i){
REP(j)cout<<ans[i][j]<<" ";cout<<endl;
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - I hate Matrix Construction |
| User | drogskol |
| Language | C++ (GCC 9.2.1) |
| Score | 600 |
| Code Size | 2272 Byte |
| Status | AC |
| Exec Time | 481 ms |
| Memory | 18340 KiB |
Compile Error
./Main.cpp: In function ‘void AL()’:
./Main.cpp:32:14: warning: comparison of integer expressions of different signedness: ‘int’ and ‘ul’ {aka ‘long long unsigned int’} [-Wsign-compare]
32 | if(s[i]==U){
| ^
./Main.cpp:38:14: warning: comparison of integer expressions of different signedness: ‘int’ and ‘ul’ {aka ‘long long unsigned int’} [-Wsign-compare]
38 | if(t[j]==V){
| ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:61:24: warning: comparison of integer expressions of different signedness: ‘int’ and ‘ul’ {aka ‘long long unsigned int’} [-Wsign-compare]
61 | REP(i)REP(j)if(s[i]==U&&U==t[j]&&t[j]==V)F(s[i]);
| ^
./Main.cpp:61:30: warning: comparison of integer expressions of different signedness: ‘ul’ {aka ‘long long unsigned int’} and ‘int’ [-Wsign-compare]
61 | REP(i)REP(j)if(s[i]==U&&U==t[j]&&t[j]==V)F(s[i]);
| ^
./Main.cpp:61:42: warning: comparison of integer expressions of different signedness: ‘int’ and ‘ul’ {aka ‘long long unsigned int’} [-Wsign-compare]
61 | REP(i)REP(j)if(s[i]==U&&U==t[j]&&t[j]==V)F(s[i]);
| ^
./Main.cpp:16:16: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
16 | #define REP(i) for(int i=0;i<n;i++)
| ^~~
./Main.cpp:109:5: note: in expansion of macro ‘REP’
109 | REP(j)cout<<ans[i][j]<<" ";cout<<endl;
| ^~~
./Main.cpp:109:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
109 | REP(j)cout<<ans[i][j]<<" ";cout<<endl;
| ^~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 600 / 600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample1.txt, sample2.txt |
| All | anti-beet1.txt, anti-beet2.txt, anti-beet3.txt, anti-beet4.txt, anti-beet5.txt, anti-beet6.txt, anti-beet7.txt, anti-beet8.txt, anti_beet_alpha.txt, anti_beet_beta.txt, anti_beet_delta.txt, anti_beet_theta.txt, brute1.txt, brute2.txt, brute3.txt, brute4.txt, brute5.txt, brute6.txt, brute7.txt, brute8.txt, brute9.txt, ng3.txt, random1.txt, random2.txt, sample1.txt, sample2.txt, test0.txt, test1.txt, test10.txt, test11_.txt, test12_.txt, test13_.txt, test14.txt, test15.txt, test16.txt, test17_.txt, test18_.txt, test19_.txt, test2.txt, test20_.txt, test21_.txt, test22_.txt, test3.txt, test4.txt, test5.txt, test6.txt, test7.txt, test8.txt, test9.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| anti-beet1.txt | AC | 228 ms | 13356 KiB |
| anti-beet2.txt | AC | 237 ms | 16544 KiB |
| anti-beet3.txt | AC | 250 ms | 12464 KiB |
| anti-beet4.txt | AC | 227 ms | 13196 KiB |
| anti-beet5.txt | AC | 160 ms | 8256 KiB |
| anti-beet6.txt | AC | 325 ms | 18212 KiB |
| anti-beet7.txt | AC | 154 ms | 8512 KiB |
| anti-beet8.txt | AC | 397 ms | 18228 KiB |
| anti_beet_alpha.txt | AC | 322 ms | 18340 KiB |
| anti_beet_beta.txt | AC | 481 ms | 18280 KiB |
| anti_beet_delta.txt | AC | 332 ms | 18204 KiB |
| anti_beet_theta.txt | AC | 409 ms | 18112 KiB |
| brute1.txt | AC | 8 ms | 4564 KiB |
| brute2.txt | AC | 13 ms | 4564 KiB |
| brute3.txt | AC | 7 ms | 4540 KiB |
| brute4.txt | AC | 8 ms | 4556 KiB |
| brute5.txt | AC | 7 ms | 4508 KiB |
| brute6.txt | AC | 7 ms | 4420 KiB |
| brute7.txt | AC | 7 ms | 4592 KiB |
| brute8.txt | AC | 6 ms | 4564 KiB |
| brute9.txt | AC | 10 ms | 4436 KiB |
| ng3.txt | AC | 167 ms | 6328 KiB |
| random1.txt | AC | 260 ms | 13404 KiB |
| random2.txt | AC | 231 ms | 13484 KiB |
| sample1.txt | AC | 6 ms | 4556 KiB |
| sample2.txt | AC | 10 ms | 4376 KiB |
| test0.txt | AC | 7 ms | 4612 KiB |
| test1.txt | AC | 21 ms | 4944 KiB |
| test10.txt | AC | 204 ms | 8268 KiB |
| test11_.txt | AC | 202 ms | 8160 KiB |
| test12_.txt | AC | 199 ms | 7872 KiB |
| test13_.txt | AC | 201 ms | 8252 KiB |
| test14.txt | AC | 8 ms | 4432 KiB |
| test15.txt | AC | 168 ms | 6452 KiB |
| test16.txt | AC | 173 ms | 6504 KiB |
| test17_.txt | AC | 202 ms | 8252 KiB |
| test18_.txt | AC | 202 ms | 8216 KiB |
| test19_.txt | AC | 203 ms | 8132 KiB |
| test2.txt | AC | 18 ms | 4996 KiB |
| test20_.txt | AC | 206 ms | 8112 KiB |
| test21_.txt | AC | 203 ms | 8244 KiB |
| test22_.txt | AC | 200 ms | 7896 KiB |
| test3.txt | AC | 42 ms | 5152 KiB |
| test4.txt | AC | 202 ms | 8116 KiB |
| test5.txt | AC | 204 ms | 8140 KiB |
| test6.txt | AC | 203 ms | 8044 KiB |
| test7.txt | AC | 204 ms | 8148 KiB |
| test8.txt | AC | 206 ms | 8156 KiB |
| test9.txt | AC | 203 ms | 8384 KiB |