답안 #1079037

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079037 2024-08-28T09:47:31 Z anton Tiles (BOI24_tiles) C++17
0 / 100
62 ms 6860 KB
#include<bits/stdc++.h>

using namespace std;
#define int long long
#define pt complex<int>
#define pii pair<int, int>
int N, M;
vector<pt> points; 
signed main(){
    cin>>N>>M;

    vector<vector<int>> col_range(M);
    for(int i = 0; i<N; i++){
        int a, b;
        cin>>a>>b;
        points.push_back({a, b});
    }

    pt prev= points.back();
    for(int i = 0; i<N; i++){
        pt edge = points[i]-prev;

        if(edge.imag() == 0){
            pii range = {min(points[i].real(), prev.real()), max(points[i].real(), prev.real())};
            for(int j = range.first; j<range.second; j++){
                col_range[j].push_back(points[i].imag());
            }
        }
        prev=  points[i];
    }

    for(int i = 0; i<M; i++){
        sort(col_range[i].begin(), col_range[i].end());
    }

    int k =-1;
    bool ok = true;
    while(ok && k<=M-3){

        for(int i = 0; i<col_range[k+1].size(); i+=2){
            if((col_range[k+1][i+1]-col_range[k+1][i])%2 != 0){
                ok = false;
            }
        }
        if(col_range[k+1].size() != col_range[k+2].size()){
            ok  = false;
        }
        else{
            for(int i = 0; i<col_range[k+1].size(); i++){
                if(col_range[k+1][i] != col_range[k+2][i]){
                    ok = false;
                }
            }
        }
        if(ok){
            k+=2;
        }
    }
    cout<<k+1<<endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:40:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int i = 0; i<col_range[k+1].size(); i+=2){
      |                        ~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:49:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |             for(int i = 0; i<col_range[k+1].size(); i++){
      |                            ~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 2 ms 604 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 2 ms 604 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 3 ms 704 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 62 ms 6860 KB Output is correct
6 Correct 58 ms 6840 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 3 ms 864 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Incorrect 2 ms 1116 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 2 ms 604 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -