답안 #121301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121301 2019-06-26T09:57:28 Z DodgeBallMan Flood (IOI07_flood) C++14
45 / 100
97 ms 6552 KB
#include <bits/stdc++.h>
#define ppi pair<pair<int, int>, int>
#define pii pair<int, int>
#define x first
#define y second

using namespace std;

const int N = 1e5 + 10;
pii p[N];
vector<ppi> v;
vector<int> ans;
int n, w, to, dir, wall, now, ty, f[N], t[N], chk[2*N][2], di[2*N][4], visit[2*N];
int main()
{
    scanf("%d",&n);
    for( int i = 1 ; i <= n ; i++ ) scanf("%d %d",&p[i].x,&p[i].y);
    scanf("%d",&w);
    for( int i = 1 ; i <= w ; i++ ) {
        scanf("%d %d",&f[i],&t[i]);
        if( p[f[i]].x > p[t[i]].x || p[f[i]].y > p[t[i]].y ) swap( f[i], t[i] );
		if( p[f[i]].x == p[t[i]].x ) di[f[i]][3] = i, di[t[i]][1] = i;
		else di[f[i]][0] = i, di[t[i]][2] = i;
        v.emplace_back( ppi( pii( p[t[i]].x, -1*p[t[i]].y ), i ) );
    }
    sort( v.begin(), v.end(), greater<ppi>() );
    for( int i = 0 ; i < v.size() ; i++ ) {
        wall = v[i].y; 
        if( visit[wall] ) continue;
        now = f[wall], ty = p[f[i]].y == p[t[i]].y ? 2 : 1;
        vector<int> outside;
        while( 1 ) {
            for( int j = 0 ; j < 4 ; j++ ) {
                dir = ( ty + j + 3 ) % 4;
                to = di[now][dir];
                if( to > 0 && !visit[to] ) break; 
            }
            if( chk[to][dir/2] ) break;
            chk[to][dir/2] = 1;
            outside.emplace_back( to );
            ty = dir;
            if( now == f[to] ) now = t[to];
            else now = f[to];
        }
        for( int j = 0 ; j < outside.size() ; j++ ) {
            //printf("%d ",outside[i]);
            visit[outside[j]] = 1;
        }
        //printf("\n");
    }
    for( int i = 1 ; i <= w ; i++ ) if( chk[i][0] > 0 && chk[i][1] > 0 ) ans.emplace_back( i );
    printf("%d\n",ans.size());
    for( int i = 0 ; i < ans.size() ; i++ ) printf("%d ",ans[i]);
    return 0;
}

Compilation message

flood.cpp: In function 'int main()':
flood.cpp:27:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i = 0 ; i < v.size() ; i++ ) {
                      ~~^~~~~~~~~~
flood.cpp:45:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for( int j = 0 ; j < outside.size() ; j++ ) {
                          ~~^~~~~~~~~~~~~~~~
flood.cpp:52:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",ans.size());
                   ~~~~~~~~~~^
flood.cpp:53:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i = 0 ; i < ans.size() ; i++ ) printf("%d ",ans[i]);
                      ~~^~~~~~~~~~~~
flood.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
flood.cpp:17:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for( int i = 1 ; i <= n ; i++ ) scanf("%d %d",&p[i].x,&p[i].y);
                                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
flood.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&w);
     ~~~~~^~~~~~~~~
flood.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&f[i],&t[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 2100 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 5720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 5764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 97 ms 6348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 94 ms 6552 KB Output isn't correct
2 Halted 0 ms 0 KB -