QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#245598 | #7680. Subway | UNos_maricones# | WA | 1ms | 3860kb | C++20 | 2.4kb | 2023-11-10 04:58:29 | 2023-11-10 04:58:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int A = 50;
const int X = 1000;
typedef pair< int, int > pii;
#define ff first
#define ss second
int main()
{
int n;
scanf("%d", &n );
vector< vector< pii > > v ( A );
int ans = 0;
for( int i = 0; i < n; ++ i )
{
int x, y, a;
scanf("%d %d %d", &x, &y, &a );
ans = max( ans, a );
for( int it = 0; it < a; ++ it )
v[it].push_back( make_pair( x, y ) );
}
printf("%d\n", ans );
const int L0 = 2 * ( 2 * X + 1 );
printf("%d", L0 );
for( int x = -X; x <= X; ++ x )
{
if( abs( x ) % 2 == 0 )
{
printf(" %d %d", x, X );
printf(" %d %d", x, -X );
}
else
{
printf(" %d %d", x, -X );
printf(" %d %d", x, X );
}
}
puts("");
int Y = 10 * X;
for( int it = 1; it < ans; ++ it )
{
auto vp = v[it];
sort( vp.begin(), vp.end(), [&] ( auto &p, auto &q ) {
if( p.ff != q.ff ) return p.ff < q.ff;
if( abs( p.ff ) % 2 == 0 )
return p.ss > q.ss;
return p.ss < q.ss;
});
if( (int) vp.size() == 1 ) //need to add one point
{
auto p = vp[0];
printf("2");
//down always
if( abs( p.ff ) % 2 == 0 )
printf(" %d %d", p.ff - 1, -Y );
else
printf(" %d %d", p.ff + 1, -Y );
++Y;
printf(" %d %d\n", p.ff, p.ss );
continue;
}
vector< pii > vl;
const int sz = (int) vp.size();
for( int i = 0; i < sz - 1; ++ i )
{
auto from = vp[i], to = vp[i+1];
vl.push_back( from );
if( to.ff <= from.ff + 1 ) continue;
if( abs( to.ff ) % 2 == 0 )//down
{
if( abs( from.ff ) % 2 == 0 )
vl.push_back( make_pair( from.ff - 1, -Y ) );
else
vl.push_back( make_pair( from.ff + 1, -Y ) );
++Y;
vl.push_back( make_pair( to.ff - 1, -Y ) );
++Y;
}
else//up
{
if( abs( from.ff ) % 2 == 0 )
vl.push_back( make_pair( from.ff + 1, Y ) );
else
vl.push_back( make_pair( from.ff - 1, Y ) );
++Y;
vl.push_back( make_pair( to.ff - 1, Y ) );
++Y;
}
}
vl.push_back( vp.back() );
printf("%d", (int) vl.size() );
for( auto &p : vl )
printf(" %d %d", p.first, p.second );
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3860kb
input:
3 1 2 1 2 1 2 3 3 2
output:
2 4002 -1000 1000 -1000 -1000 -999 -1000 -999 1000 -998 1000 -998 -1000 -997 -1000 -997 1000 -996 1000 -996 -1000 -995 -1000 -995 1000 -994 1000 -994 -1000 -993 -1000 -993 1000 -992 1000 -992 -1000 -991 -1000 -991 1000 -990 1000 -990 -1000 -989 -1000 -989 1000 -988 1000 -988 -1000 -987 -1000 -987 10...
result:
wrong answer Segment passing through station on polyline 1.