Submission #791444

# Submission time Handle Problem Language Result Execution time Memory
791444 2023-07-24T06:36:32 Z Amylopectin Roads (CEOI20_roads) C++14
15 / 100
72 ms 7828 KB
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long mxn = 1e6 + 10,mxi = 2e7 + 10;
struct we
{
    long long xx,yy,xx2,yy2;
    double slo,soo;
};
bool cmp(const struct we &l,const struct we &r)
{
    if(l.soo != r.soo)
        return l.soo < r.soo;
    if(l.xx != r.xx)
        return l.xx < r.xx;
    return l.yy < r.yy;
}
struct we ta[mxn] = {};
int main()
{
    long long i,j,n,m,cn,cm,fn,fm,f,sta = 0;
    double t,p,cslo;
    scanf("%lld",&n);
    for(i=0; i<n; i++)
    {
        scanf("%lld %lld %lld %lld",&cn,&cm,&fn,&fm);
        if(cn > fn || (cn == fn && cm > fm))
        {
            f = cn;
            cn = fn;
            fn = f;
            f = cm;
            cm = fm;
            fm = f;
        }
        ta[i] = {cn,cm,fn,fm,0,0};
        if(fn - cn == 0)
        {
            // sta = 1;
            ta[i].slo = mxi;
            cslo = mxi;
        }
        else 
        {
            t = fm - cm;
            p = fn - cn;
            ta[i].slo = t / p;
            cslo = t/p;
        }
    }
    if(sta == 1)
    {
        for(i=0; i<n; i++)
        {
            ta[i].soo = ta[i].xx;
        }
    }
    else 
    {
        for(i=0; i<n; i++)
        {
            t = ta[i].xx;
            f = ta[i].yy;
            ta[i].soo = f - t * cslo;
        }
    }
    sort(ta,ta+n,cmp);
    printf("\n");
    for(i=0; i<n-1; i++)
    {
        // if(ta[i].soo != ta[i+1].soo)
        // {
        //     printf("%lld %lld %lld %lld\n",ta[i].xx,ta[i].yy,ta[i+1].xx,ta[i+1].yy);
        // }
        // else 
        // {
            printf("%lld %lld %lld %lld\n",ta[i].xx2,ta[i].yy2,ta[i+1].xx,ta[i+1].yy);
        // }
    }
    return 0;
}

Compilation message

roads.cpp: In function 'int main()':
roads.cpp:23:17: warning: unused variable 'j' [-Wunused-variable]
   23 |     long long i,j,n,m,cn,cm,fn,fm,f,sta = 0;
      |                 ^
roads.cpp:23:21: warning: unused variable 'm' [-Wunused-variable]
   23 |     long long i,j,n,m,cn,cm,fn,fm,f,sta = 0;
      |                     ^
roads.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
roads.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%lld %lld %lld %lld",&cn,&cm,&fn,&fm);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Failed 0 ms 212 KB Condition failed: "!Cross(S[*pi], S[*pa])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 7 ms 1036 KB Output is correct
5 Correct 15 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 7 ms 980 KB Output is correct
5 Correct 14 ms 1788 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 8 ms 980 KB Output is correct
10 Failed 72 ms 7828 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 7 ms 1048 KB Output is correct
5 Correct 16 ms 1780 KB Output is correct
6 Failed 0 ms 212 KB Condition failed: "!Cross(S[*pi], S[*pa])"
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 0 ms 212 KB Condition failed: "!Cross(S[*pi], S[*pa])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 0 ms 212 KB Condition failed: "!Cross(S[*pi], S[*pa])"
2 Halted 0 ms 0 KB -