답안 #711788

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
711788 2023-03-17T13:50:19 Z pcc Slagalica (COCI19_slagalica2) C++14
70 / 70
38 ms 7992 KB
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fs first
#define sc second
vector<int> v[9];
int deg[9];
pii dif[] = {{0,0},{-1,1},{-1,-1},{1,1},{1,-1},{-2,1},{-2,-1},{-1,2},{1,2}};
vector<int> ans;
const int mxn = 1e5+10;
bitset<mxn> vis;
struct Edge{
    int to,val,id;
    Edge(){}
    Edge(int tt,int vv,int ii){
        id = ii;
        to = tt;
        val = vv;
    }
    bool operator<(Edge &b){
        return val<b.val;
    }
};
vector<Edge> paths[9];
int ptr[9];
void dfs(int now){
    while(!paths[now].empty()){
        auto nxt = paths[now].back().to,val = paths[now].back().val;
        paths[now].pop_back();
        dfs(nxt);
        ans.push_back(val);
    }
    return;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i = 0;i<n;i++){
        int a,b;
        cin>>a>>b;
        paths[dif[a].fs+4].push_back(Edge(dif[a].sc+4,b,i));
        deg[dif[a].sc+4]++;
        deg[dif[a].fs+4]--;
    }
    if(paths[2].size()!=1||deg[6] != 1){
        cout<<"-1";
        return 0;
    }
    // paths[6].push_back({2,0});
    for(int i = 3;i<=5;i++){
        if(deg[i] != 0){
            cout<<-1;
            return 0;
        }
    }
    for(auto &i:paths)sort(i.rbegin(),i.rend());
    dfs(2);
    while(!ans.empty())cout<<ans.back()<<' ',ans.pop_back();return 0;
}

Compilation message

slagalica.cpp: In function 'int main()':
slagalica.cpp:60:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   60 |     while(!ans.empty())cout<<ans.back()<<' ',ans.pop_back();return 0;
      |     ^~~~~
slagalica.cpp:60:61: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   60 |     while(!ans.empty())cout<<ans.back()<<' ',ans.pop_back();return 0;
      |                                                             ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 7120 KB Output is correct
2 Correct 15 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 6908 KB Output is correct
2 Correct 14 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1804 KB Output is correct
2 Correct 30 ms 6888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1612 KB Output is correct
2 Correct 28 ms 6788 KB Output is correct
3 Correct 34 ms 6632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 5248 KB Output is correct
2 Correct 13 ms 1808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 6840 KB Output is correct
2 Correct 16 ms 1808 KB Output is correct
3 Correct 31 ms 6524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1744 KB Output is correct
2 Correct 30 ms 6908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 7992 KB Output is correct
2 Correct 21 ms 1616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 6764 KB Output is correct
2 Correct 14 ms 1776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 7872 KB Output is correct
2 Correct 14 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 6720 KB Output is correct
2 Correct 15 ms 1540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 6784 KB Output is correct
2 Correct 16 ms 1608 KB Output is correct