QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#360069#4892. 序列dengtingyu0 4ms31996kbC++142.3kb2024-03-21 11:08:252024-03-21 11:08:25

Judging History

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

  • [2024-03-21 11:08:25]
  • 评测
  • 测评结果:0
  • 用时:4ms
  • 内存:31996kb
  • [2024-03-21 11:08:25]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100010
ll n,m;
unordered_map<ll,ll>dui[N];ll cn=1;
vector<ll>ji[N],bh[N];
ll u[N][3],val[N];
#define M 1000100
ll fir[M],v[M],nxt[M];ll cnt=0;
inline void Add(ll x,ll y){v[++cnt]=y;nxt[cnt]=fir[x];fir[x]=cnt;return ;}
inline void add(ll x,ll y){Add(x,y);Add(y^1,x^1);return ;}
ll dfn[M],low[M],dfncnt=0,col[M],colcnt=0;
ll st[M],top=0;
inline void tar(ll x){
    dfn[x]=low[x]=++dfncnt;st[++top]=x;
    for(int i=fir[x];i;i=nxt[i]){
        ll vi=v[i];if(!dfn[vi]){
            tar(vi);
            low[x]=min(low[x],low[vi]);
        }else if(!col[vi])low[x]=min(low[x],dfn[vi]);
    }if(dfn[x]==low[x]){
        col[x]=++colcnt;
        while(st[top]!=x){
            col[st[top]]=colcnt;top--;
        }top--;
    }return ;
}
int main(){
    // freopen("test1.in","r",stdin);
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;for(int i=1,x,y,z,d;i<=m;i++){
        cin>>x>>y>>z>>d;ji[x].push_back(d);ji[y].push_back(d);ji[z].push_back(d);
        u[i][0]=x;u[i][1]=y;u[i][2]=z;val[i]=d;
    }for(int i=1;i<=n;i++)if(ji[i].empty())ji[i].push_back(1);
    for(int i=1;i<=n;i++){
        sort(ji[i].begin(),ji[i].end());
        for(int j=0;j<ji[i].size();j++)dui[i][ji[i][j]]=j,bh[i].push_back(++cn),cn++;
        for(int j=0;j+1<ji[i].size();j++)add(bh[i][j],bh[i][j+1]);
        add(bh[i][0],bh[i][0]^1);
    }for(int i=1;i<=m;i++){
        ll d=val[i];auto *x=u[i];ll tt=x[0];
        ll p[3];for(int j=0;j<=2;j++)p[j]=dui[x[j]][d];
        for(int j=0;j<=2;j++){
            for(int k=0;k<=2;k++)if(j!=k)add(bh[x[j]][p[j]],bh[x[k]][p[k]]^1);
        }for(int j=0;j<=2;j++){
            for(int k=0;k<=2;k++){
                if(j==k||p[j]+1>=ji[j].size())continue;
                ll tem=bh[x[j]][p[j]+1];
                if(p[k]+1<ji[k].size())tem=bh[k][p[k]+1];
                add(bh[x[j]][p[j]+1]^1,tem);
            }
        }
    }for(int i=2;i<=cn;i++)if(!dfn[i])tar(i);    
    ll kz=0;for(int i=1;i<=n;i++){
        for(int j=0;j<ji[i].size();j++)if(col[bh[i][j]]==col[bh[i][j]^1]){kz=1;break;}if(kz)break;  
    }if(kz){cout<<"NO";return 0;}cout<<"YES"<<'\n';
    for(int i=1;i<=n;i++){
        ll an=0;for(int j=0;j<ji[i].size();j++)if(col[bh[i][j]]>col[bh[i][j]^1])an=ji[i][j];
        cout<<an<<' ';
    }return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 20276kb

input:

10 10
6 3 10 133562624
8 7 6 685486592
4 2 7 332482851
10 8 9 211550017
2 10 1 165556251
10 8 5 211550017
6 8 2 332482851
4 9 2 332482851
8 1 4 193658790
9 6 10 728674154

output:

NO

result:

wrong answer verdict is not correct

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 4ms
memory: 31996kb

input:

40 9880
4 19 31 610502845
10 19 33 190412843
21 24 39 649028784
16 22 40 569593239
5 9 37 550862419
11 23 40 654613112
6 18 23 492267246
22 23 30 538715841
6 16 24 407919735
5 16 18 388907784
2 16 18 388907784
21 24 28 281403057
7 12 27 451830401
3 11 16 508407438
15 33 36 561955959
6 23 29 70605893...

output:

NO

result:

wrong answer verdict is not correct

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #2:

0%