QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#586974 | #9319. Bull Farm | Alliy666 | WA | 26ms | 4004kb | C++23 | 2.1kb | 2024-09-24 16:53:05 | 2024-09-24 16:53:05 |
Judging History
answer
#include <bits/extc++.h>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
const int maxn=2005;
int tt[maxn],s[maxn];
bitset<maxn> flag;
class A
{
public:
int to,val;
};
vector<A> G[maxn];
class B
{
public:
int num,dis;
bool operator<(const B&that)const
{
return dis>that.dis;
}
};
int dis[maxn][maxn];
int input()
{
int ans=0;
int a='\n',b='\n';
while(a=='\n')
a=getchar();
while(b=='\n')
b=getchar();
return 50*(a-48)+b-48;
}
int find(int d)
{
if(s[d]!=d)
s[d]=find(s[d]);
return s[d];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t,n,l,q,u,v,a,b,c;
scanf("%d",&t);
while (t--)
{
scanf("%d %d %d\n",&n,&l,&q);
for(int i=1;i<=n;i++)
{
s[i]=i;
G[i].clear();
}
for(int i=1;i<=l;i++)
{
flag.reset();
for(int j=1;j<=n;j++)
{
tt[j]=input();
flag[tt[j]]=1;
}
int cnt=flag.count();
if(cnt==n)
{
for(int j=1;j<=n;j++)
{
u=find(j);
v=find(tt[j]);
if(u!=v)
{
s[u]=v;
G[j].push_back({tt[j],i});
G[tt[j]].push_back({j,i});
}
}
}
else if(cnt==n-1)
{
gp_hash_table<int,int> mp;
flag.flip();
v=flag._Find_next(0);
for(int j=1;j<=n;j++)
{
if(mp.find(tt[j])==mp.end())
mp[tt[j]]=j;
else
{
G[mp[tt[j]]].push_back({v,i});
G[j].push_back({v,i});
break;
}
}
}
}
for(int i=1;i<=n;i++)
{
std::priority_queue<B> q;
q.push({i,0});
for(int j=1;j<=n;j++)
{
if(j!=i)
dis[i][j]=2147483647;
else
dis[i][j]=0;
}
while(!q.empty())
{
B now=q.top();
q.pop();
if(dis[i][now.num]!=now.dis)
continue;
for(auto j:G[now.num])
{
if(dis[i][j.to]>j.val)
{
dis[i][j.to]=j.val;
q.push({j.to,j.val});
}
}
}
}
while (q--)
{
a=input();
b=input();
c=input();
if(dis[a][b]<=c)
putchar('1');
else
putchar('0');
}
putchar('\n');
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3716kb
input:
2 5 2 4 0305040201 0404040404 030300 020500 050102 020501 6 2 4 030603010601 010203060504 030202 060402 050602 060401
output:
1011 0100
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 4004kb
input:
1 3 3 6 020202 030301 030201 020102 030203 010201 010303 020303 010202
output:
010101
result:
ok single line: '010101'
Test #3:
score: -100
Wrong Answer
time: 26ms
memory: 3988kb
input:
200 10 10 5000 01060:04020305080709 0103070:060204050908 09070503080401060:02 050308010204090:0607 03010502040607080:09 03080109020504060:07 06050:09040302080107 07080305010409060:02 030809010:0204060507 0:060908070201050304 060700 090:03 09080: 070405 010703 0:0100 080601 030600 070206 0:0:09 08040...
output:
011110101101111111111111111111111111111111110111111111111111111011010111111111111111111101111111111110111111110111111111111111111111111111111111111111111111110001110111111111111111111111111011101111111111111111111111111111111111111111111011110100111111111111111111111100111111101110111111111101111110...
result:
wrong answer 1st lines differ - expected: '011110001101101111111111111111...1111111111111111101111111111111', found: '011110101101111111111111111111...1111111111111111101111111111111'