답안 #211952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211952 2020-03-21T20:00:06 Z tatyam Flood (IOI07_flood) C++17
컴파일 오류
0 ms 0 KB
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using tuplis = array<int, 3>;
#define rep(b) for(int i = 0; i < b; i++)
#define each(i,a) for(auto&& i : a)
#define all(a) begin(a), end(a)


struct wall{
    int to, index;
    inline bool exist() const { return to + 1; }
};
int main(){
    int n;
    scanf("%d", &n);
    pii p[n];
    each(i, p) scanf("%d%d", &i.first, &i.second);
    wall g[n][4];
    each(i, g) each(j, i) j.to = -1;
    int w;
    scanf("%d", &w);
    rep(w){
        int a, b;
        scanf("%d%d", &a, &b);
        a--; b--;
        int d = 0;
        if(p[a].first < p[b].first) d = 0;
        else if(p[a].first > p[b].first) d = 2;
        else if(p[a].second < p[b].second) d = 1;
        else d = 3;
        g[a][d] = {b, i};
        g[b][d ^ 2] = {a, i};
    }
    vector<bool> ans(w, 1);
    vector<pii> visit;
    vector<int> sorted(n);
    iota(all(sorted), [&](int a, int b){ return p[a] < p[b]; });
    int i = 0;
    while(true){
        while(i < n && all_of(all(g[sorted[i]]), [](const wall& w){ return !w.exist(); })) i++;
        if(i == n) break;
        int start = sorted[i], at = start, d = 0;
        if(!g[at][d].exist()) d = 1;
        visit.clear();
        do{
            if(!g[at][d].exist()){
                d++;
                d &= 3;
                continue;
            }
            visit.emplace_back(at, d);
            ans[g[at][d].index] = !ans[g[at][d].index];
            at = g[at][d].to;
            d--;
            d &= 3;
        }while(at != start);
        each(i, visit){
            const int at = i.first, d = i.second;
            if(!g[at][d].exist()) continue;
            const int at2 = g[at][d].to, d2 = d ^ 2;
            g[at][d].to = -1;
            g[at2][d2].to = -1;
        }
    }
    printf("%d\n", accumulate(ans.begin(), ans.end(), 0));
    rep(w) if(ans[i]) printf("%d\n", i + 1);
}

Compilation message

In file included from /usr/include/c++/7/numeric:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:84,
                 from flood.cpp:4:
/usr/include/c++/7/bits/stl_numeric.h: In instantiation of 'void std::iota(_ForwardIterator, _ForwardIterator, _Tp) [with _ForwardIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Tp = main()::<lambda(int, int)>]':
flood.cpp:41:63:   required from here
/usr/include/c++/7/bits/stl_numeric.h:93:13: error: cannot convert 'main()::<lambda(int, int)>' to 'int' in assignment
    *__first = __value;
    ~~~~~~~~~^~~~~~~~~
/usr/include/c++/7/bits/stl_numeric.h:94:4: error: no match for 'operator++' (operand type is 'main()::<lambda(int, int)>')
    ++__value;
    ^~~~~~~~~
flood.cpp: In function 'int main()':
flood.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
flood.cpp:21:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     each(i, p) scanf("%d%d", &i.first, &i.second);
                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flood.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &w);
     ~~~~~^~~~~~~~~~
flood.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~