QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#692864 | #5520. Distance Parities | ucup-team4717 | WA | 1ms | 7848kb | C++17 | 2.4kb | 2024-10-31 15:08:45 | 2024-10-31 15:08:48 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace IO{
char buff[1<<21],*p1=buff,*p2=buff;
char getch(){
return p1==p2&&(p2=((p1=buff)+fread(buff,1,1<<21,stdin)),p1==p2)?EOF:*p1++;
}
template<typename T>
void read(T &x){
char ch=getch();int fl=1;x=0;
while(ch>'9'||ch<'0'){if(ch=='-')fl=-1;ch=getch();}
while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getch();}
x*=fl;
}
template<typename T,typename ...Args>
void read(T &x,Args& ...args){
read(x);read(args...);
}
char obuf[1<<21],*p3=obuf;
void putch(char ch){
if(p3-obuf<(1<<21))*p3++=ch;
else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=ch;
}
void put(const char *s){while(*s)putch(*s),s++;}
char ch[100];
template<typename T>
void write(T x){
if(!x)return putch('0');
if(x<0)putch('-'),x*=-1;
int top=0;
while(x)ch[++top]=x%10+48,x/=10;
while(top)putch(ch[top]),top--;
}
template<typename T,typename ...Args>
void write(T x,Args ...args){
write(x),putch(' '),write(args...);
}
void flush(){fwrite(obuf,p3-obuf,1,stdout);}
}
using namespace IO;
bool ST;
const int N=505;
int n;
int b[N][N];
vector<int>to[N];
int vis[N],dis[N][N];
queue<int>q;
bool EN;
bool dijk(int S){
fill(vis+1,vis+n+1,0);
dis[S][S]=0;vis[S]=1;
q.push(S);
while(!q.empty()){
int x=q.front();q.pop();
for(auto y:to[x]){
if(!vis[y]){
dis[S][y]=dis[S][x]^1;
vis[y]=1;
q.push(y);
}
}
}
for(int i=1;i<=n;i++)
if(!vis[i])return 0;
return 1;
}
void sol(){
read(n);
for(int i=1;i<=n;i++)to[i].clear();
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
char ch=getch();
while(!isdigit(ch))ch=getch();
b[i][j]=ch-'0';
if(b[i][j])to[i].push_back(j);
}
}
for(int i=1;i<=n;i++){
if(!dijk(i)){
put("Track Lost\n");
return;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(dis[i][j]!=b[i][j]){
put("Track Lost\n");
return;
}
}
}
put("Pure Memory\n");
int m=0;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
m+=b[i][j];
write(m),putch('\n');
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
if(b[i][j])write(i,j),putch('\n');
return;
}
signed main(){
cerr<<(double)(&ST-&EN)/1024/1024<<"MB\n";
int T;read(T);
while(T--)sol();
flush();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7848kb
input:
3 3 011 101 110 4 0100 1000 0001 0010 5 01010 10101 01010 10101 01010
output:
Pure Memory 3 1 2 1 3 2 3 Track Lost Pure Memory 6 1 2 1 4 2 3 2 5 3 4 4 5
result:
wrong answer Token parameter [name=yes/no] equals to "Pure", doesn't correspond to pattern "[yY][eE][sS]|[nN][oO]" (test case 1)