Submission #684519

# Submission time Handle Problem Language Result Execution time Memory
684519 2023-01-21T12:14:42 Z TomitaMatei Subway (info1cup19_subway) C++14
100 / 100
8 ms 1100 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;
        }
    }
    cout<<x+ok+1<<'\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 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 440 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 2 ms 436 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 8 ms 1100 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 7 ms 1080 KB Output is correct
19 Correct 6 ms 824 KB Output is correct
20 Correct 6 ms 852 KB Output is correct