Submission #684518

# Submission time Handle Problem Language Result Execution time Memory
684518 2023-01-21T12:11:10 Z TomitaMatei Subway (info1cup19_subway) C++14
0 / 100
0 ms 212 KB
#include <iostream>
#include <cmath>
using namespace std;
struct arbore
{
    int x,y;

}v[1000001];
int n,k,x,ok,z,i;
int main()
{
    cin>>k;
    x=sqrt(k);
    while ((x+1)*(x+2)/2<=k)
        x++;
    z=k-x*(x+1)/2;
    for (i=0; i<=x; i++)
    {
        if (z==i && z!=0)
        {
            v[i].x=i;
            v[i].y=i-1;
            ok++;
            v[i+ok].x=i+ok;
            v[i+ok].y=i-1;
            i++;
            if (i<=x)
            {
                v[i+ok].x=i+ok;
                v[i+ok].y=i-1;
            }
        }
        else
        {
        v[i+ok].x=i+ok;
        v[i+ok].y=i-1+ok;
        }
    }
    if (x==0)
    {cout<<1<<'\n'; cout<<0<<" "<<-1;}
    else {cout<<x+ok<<'\n';
    for (i=0; i<=x+ok; i++)
        cout<<v[i].x<<" "<<v[i].y<<'\n';}
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB wrong number of pairs
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB wrong number of pairs
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB wrong number of pairs
3 Halted 0 ms 0 KB -