Submission #968460

# Submission time Handle Problem Language Result Execution time Memory
968460 2024-04-23T12:44:09 Z hirayuu_oj Flood (IOI07_flood) C++17
0 / 100
48 ms 8272 KB
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) x.begin(),x.end()
using ll=long long;

int dir(pair<int,int> x,pair<int,int> y){
    if(x.first==y.first){
        if(x.second<y.second)return 0;
        return 2;
    }
    if(x.first<y.first)return 1;
    return 3;
}
int wall_ind(array<pair<int,int>,4> wall){
    int cnt=0;
    int pos=-1;
    rep(i,4){
        if(wall[i].first!=-1){
            cnt++;
            pos=i;
        }
    }
    if(cnt==1)return pos;
    return -1;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin>>N;
    vector<pair<int,int>> pnt(N);
    rep(i,N){
        cin>>pnt[i].first>>pnt[i].second;
    }
    vector<array<pair<int,int>,4>> gr(N,{pair(-1,-1),pair(-1,-1),pair(-1,-1),pair(-1,-1)});
    int W;
    cin>>W;
    vector<pair<int,int>> wall(W);
    rep(i,W){
        cin>>wall[i].first>>wall[i].second;
        wall[i].first--;
        wall[i].second--;
        gr[wall[i].first][dir(pnt[wall[i].first],pnt[wall[i].second])]=pair(i,wall[i].second);
        gr[wall[i].second][dir(pnt[wall[i].second],pnt[wall[i].first])]=pair(i,wall[i].first);
    }
    vector<int> ans;
    stack<int> del;
    rep(i,N){
        if(wall_ind(gr[i])!=-1){
            del.push(i);
        }
    }
    while(!del.empty()){
        int pos=del.top();
        del.pop();
        if(wall_ind(gr[pos])==-1)continue;
        int dir=wall_ind(gr[pos]);
        ans.push_back(gr[pos][dir].first);
        gr[gr[pos][dir].second][(dir+2)%4]={-1,-1};
        if(wall_ind(gr[gr[pos][dir].second])!=-1){
            del.push(gr[pos][dir].second);
        }
        gr[pos][dir]={-1,-1};
    }
    vector<array<int,4>> vert(N,{-1,-1,-1,-1});
    int cnt=0;
    rep(i,N){
        rep(j,4){
            if(gr[i][j].first==-1)continue;
            if(vert[i][j]!=-1)continue;
            int pos=i;
            int dir=j;
            while(vert[pos][dir]==-1){
                vert[pos][dir]=cnt;
                pos=gr[pos][dir].second;
                dir=(dir+3)%4;
                while(gr[pos][dir].first==-1){
                    dir++;
                    dir%=4;
                }
            }
            cnt++;
        }
    }
    vector<vector<int>> zag(cnt);
    rep(i,W){
        int s=vert[wall[i].first][dir(pnt[wall[i].first],pnt[wall[i].second])];
        int t=vert[wall[i].second][dir(pnt[wall[i].second],pnt[wall[i].first])];
    }
    cout<<ans.size()<<"\n";
    for(int i:ans)cout<<i+1<<"\n";
}

Compilation message

flood.cpp: In function 'int main()':
flood.cpp:88:13: warning: unused variable 's' [-Wunused-variable]
   88 |         int s=vert[wall[i].first][dir(pnt[wall[i].first],pnt[wall[i].second])];
      |             ^
flood.cpp:89:13: warning: unused variable 't' [-Wunused-variable]
   89 |         int t=vert[wall[i].second][dir(pnt[wall[i].second],pnt[wall[i].first])];
      |             ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 2136 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 6224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 7004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 7844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 8272 KB Output isn't correct
2 Halted 0 ms 0 KB -