QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#579484 | #9319. Bull Farm | lmeowdn# | TL | 39ms | 5768kb | C++14 | 2.4kb | 2024-09-21 14:09:53 | 2024-09-21 14:09:53 |
Judging History
answer
//Shirasu Azusa 2024.09
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=2005;
int n,m,q,f[N][N];
int getint(char a,char b) {
return (a-48)*50+(b-48);
}
signed main() {
int T=read();
while(T--) {
n=read(), m=read(), q=read();
rep(i,1,n) rep(j,1,n) f[i][j]=m+1;
rep(i,1,n) f[i][i]=0;
rep(i,1,m) {
static char st[N*2];
scanf("%s",st); static int t[N],vs[N];
rep(i,1,n) vs[i]=0;
rep(i,1,n) {
int x=i*2-2, y=i*2-1;
t[i]=getint(st[x],st[y]);
vs[t[i]]++;
}
int xc=0,y=0;
rep(i,1,n) if(vs[i]!=1) {
if(vs[i]==0) {
if(y) {y=-1; break;}
else y=i;
} else xc=i;
}
if(y==-1) continue;
if(y==0) {
rep(j,1,n) chmin(f[j][t[j]],i);
} else {
rep(j,1,n) if(t[j]==xc) chmin(f[j][y],i);
}
}
rep(k,1,n) rep(i,1,n) rep(j,1,n) chmin(f[i][j],max(f[i][k],f[k][j]));
rep(i,1,q) {
static char st[10];
scanf("%s",st);
int a=getint(st[0],st[1]), b=getint(st[2],st[3]), c=getint(st[4],st[5]);
if(f[a][b]<=c) putchar('1');
else putchar('0');
} puts("");
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3960kb
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: 1ms
memory: 5768kb
input:
1 3 3 6 020202 030301 030201 020102 030203 010201 010303 020303 010202
output:
010101
result:
ok single line: '010101'
Test #3:
score: 0
Accepted
time: 39ms
memory: 3756kb
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:
011110001101101111111111111111111101111111110111011110110110111011010111111111111111111101111111111110111111110111111111111101111111111110111111111111111111110001100111111111111111111111111011101111111111111111111111111111111111111111011011110100111110111111110111111100111111101110111111111101111110...
result:
ok 200 lines
Test #4:
score: -100
Time Limit Exceeded
input:
1 2000 1 1000000 M=:]A@8UAY7W2JJ4KEHIA[HSCQ1ENSC`JXR;F3PJ:_@41P9Z=9HR8P<<:DUXRR9^WOQFL?NZP6S@=J0^WE32=6;\U0?88]Q_RNPUMT6YU<4<S]H?:7OCQYOT4YAV1^764ENWSDBED>M7A:BI>KSIR48JQ9B=N\5T3N4A2aF0@>3TI81<G7;YE>W`NMP<:IT4CI3D0=GZC3I\CLQJQBA9BDIS9SAM55KaVA<Z@D=>:Y?CQHUQ5U3a6UVI8OKX9_FAF^7=5M85;<0;8YPAM<7Z7PP7A=N...