Submission #1020342

# Submission time Handle Problem Language Result Execution time Memory
1020342 2024-07-12T00:41:48 Z vjudge1 Flood (IOI07_flood) C++17
33 / 100
139 ms 35856 KB
#include<bits/stdc++.h>
using namespace std;
int X[100100],Y[100100],vis[400100],lev[400100],side[100100][4][2];
vector<pair<int,int>> adj[400100];
void AE(int a,int b,int c){
    adj[a].push_back({b,c});
    adj[b].push_back({a,c});
}
int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n,w;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>X[i]>>Y[i];
    cin>>w;
    for(int i=1;i<=w;i++){
        int a,b;
        cin>>a>>b;
        if(X[a]==X[b]){
            if(Y[a]>Y[b])swap(a,b);
            side[a][2][1]=i;
            side[a][2][0]=i+w;
            side[b][0][0]=i;
            side[b][0][1]=i+w;
        } else {
            if(X[a]>X[b])swap(a,b);
            side[a][1][0]=i;
            side[a][1][1]=i+w;
            side[b][3][1]=i;
            side[b][3][0]=i+w;
        }
        AE(i,i+w,1);
    }
    for(int i=1;i<=n;i++)
        for(int j=0;j<4;j++) if(side[i][j][1])
            for(int k=(j+1)%4;;k=(k+1)%4) if(side[i][k][0]){
                AE(side[i][k][0],side[i][j][1],0);break;}
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>Q;
    memset(lev,7,sizeof lev);
    Q.push({0,1});
    lev[1]=0;
    while(Q.size()){
        auto[y,x]=Q.top(); Q.pop();
        if(vis[x])continue;
        vis[x]=1;
        for(auto[i,j]:adj[x])
            if(lev[i]>y+j)
                Q.push({lev[i]=y+j,i});
    }
    vector<int>v;
    for(int i=1;i<=w;i++)
        if(lev[i]==lev[i+w])
            v.push_back(i);
    cout<<v.size()<<'\n';
    for(auto i:v)
        cout<<i<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12888 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 12892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 12892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 12888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 12892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 12892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 15964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 26316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 27408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 93 ms 33484 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 139 ms 35856 KB Memory limit exceeded
2 Halted 0 ms 0 KB -