답안 #240203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240203 2020-06-18T15:43:53 Z DavidDamian Checker (COCI19_checker) C++11
0 / 110
15 ms 768 KB
#include <bits/stdc++.h>
using namespace std;
///Subtask 1
///O(n^3)
#define debug(x) cout<<#x<<" = "<<x<<endl
struct edge
{
    int from,to;
    edge(){}
    edge(int from,int to) : from(from),to(to){}
};
int n;
int color[305][305];
int segments[305];
bool checkTriang()
{
    vector<edge> edges;
    for(int i=1;i<=n-3;i++){
        int a,b,c;
        cin>>a>>b>>c;
        if(color[a][b]!=0)
            return false;
        color[a][b]=color[b][a]=c;
        for(edge e: edges){
            for(int u=e.from+1;u!=e.to;u=(u<n)? u+1 : 1){
                segments[u]=1;
            }
            for(int u=e.to+1;u!=e.from;u=(u<n)? u+1 : 1){
                segments[u]=2;
            }
            if(segments[a]!=0 && segments[b]!=0 && segments[a]!=segments[b])
                return false;
            for(int u=e.from+1;u!=e.to;u=(u<n)? u+1 : 1){
                segments[u]=0;
            }
            for(int u=e.to+1;u!=e.from;u=(u<n)? u+1 : 1){
                segments[u]=0;
            }
        }
        edges.push_back(edge(a,b));
    }
    return true;
}
bool checkColor()
{
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(color[i][j]==0) continue;
            for(int k=j+1;k<=n;k++){
                if(color[i][k]==0 || color[j][k]==0) continue;
                if(color[i][j]==color[i][k]
                   || color[i][k]==color[j][k]
                   || color[i][j]==color[j][k])
                    return false;
            }
        }
    }
    return true;
}
int main()
{
    cin>>n;
    if(n>300)
        return 0;
    for(int i=1;i<=n;i++){
        int j=(i<n)? i+1 : 1;
        char c;
        cin>>c;
        color[i][j]=color[j][i]=c-'0';
    }
    if(checkTriang()==false){
        cout<<"neispravna triangulacija";
        return 0;
    }
    if(checkColor()==false){
        cout<<"neispravno bojenje";
        return 0;
    }
    cout<<"tocno";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -