QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#415068#6705. MedianxiaoleWA 29ms4028kbC++231.3kb2024-05-20 09:03:042024-05-20 09:03:05

Judging History

你现在查看的是最新测评结果

  • [2024-05-20 09:03:05]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:4028kb
  • [2024-05-20 09:03:04]
  • 提交

answer

#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;using ll = long long;using PLL = pair<ll,ll>;
const ll MAX = 1e18;const ll MIN = -1e18;const ll INF=0x3f3f3f3f;
const ll Q = 2000+9;const ll MOD = 1e9 + 7;
vector<ll> s[Q];
vector<ll> x[Q];
bool vis[Q];
ll dfs(ll now){
    ll cnt=1;
    if(vis[now]){
        return -1;
    }
    vis[now]=true;
    for(auto i:s[now]){
        cnt+=dfs(i);
    }
    return cnt;
}
ll dfs2(ll now){
    ll cnt=1;
    if(vis[now]){
        return -1;
    }
    vis[now]=true;
    for(auto i:x[now]){
        cnt+=dfs2(i);
        
    }
    return cnt;
}
ll ans[Q];
void solve(){
   ll n,m;cin>>n>>m;
   memset(ans,0,sizeof ans);
   bool ok=true;
   for (ll i = 1; i <= m; i++)
   {
    ll o,p;cin>>o>>p;
    if(o==p) ok=false;
    x[o].push_back(p);
    s[p].push_back(o);
   }
   if(ok==false){
    for (ll i = 1; i <= n; i++)
    {
        cout<<0;
    }cout<<"\n";
    return;
   }
    for (ll i = 1; i <= n; i++)
    {
        memset(vis,0,sizeof vis);
        ll l=dfs(i)-1;
        memset(vis,0,sizeof vis);
        ll r=dfs2(i)-1;
        if(l<=n/2 and r<=n/2) cout<<1;
        else cout<<0;
    }cout<<"\n";
}
int main(){
    ios;ll _=1;cin>>_;
    while (_--)solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3708kb

input:

2
5 4
1 2
3 2
2 4
2 5
3 2
1 1
2 3

output:

01000
000

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 29ms
memory: 4028kb

input:

66
13 2
9 13
7 11
11 19
9 1
8 1
5 1
2 8
4 2
2 1
5 2
6 3
3 11
3 2
4 6
6 10
9 8
3 5
1 7
5 8
3 9
4 9
6 7
3 1
2 3
11 6
9 4
1 6
5 2
1 5
4 6
8 4
15 15
10 6
15 8
7 6
11 1
5 2
3 4
11 13
4 6
10 12
10 13
1 6
15 2
5 12
13 14
5 3
15 86
14 12
8 1
14 9
8 15
5 10
1 9
11 2
6 2
7 10
10 13
14 5
4 13
5 8
4 10
13 9
6 9...

output:

1111111111111
11111111111
011
11111111111
111111111111111
111111111111111
11111
11111
1111111
1111111111111
111111111
111111111
111111111111111
111111111
111111111
1111111111111
1111111111111
111111111111111
11111111111
111111111111111
11111111111
11111111111
11111
11111111111
11111111111
11111
1111...

result:

wrong answer 2nd lines differ - expected: '01001000111', found: '11111111111'