Submission #548931
Source Code Expand
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C
{
class MyCell
{
public long 番地;
public int color;
}
class Program
{//なんでNの条件は問題文に書かないんだ
static void Main(string[] args)
{
//白黒境目のデータを作る
LinkedList<MyCell> list = new LinkedList<MyCell>();
list.AddFirst(new MyCell { 番地 = 0, color = 0 });
//番地とその続きの色を指定するリスト
//せいぜい10^15
//0~10^9の範囲の探索補助は要るかな
int N = int.Parse(Tempo.ReadString());
long[] Answer = new long[N];//long[]とint[]の無条件変換;
for(int i = 0; i < N; i++)
{
long S = long.Parse(Tempo.ReadString()), C = long.Parse(Tempo.ReadString());
long Now = S - 1;//beforeを変えてこれを変える
long Count = C - 1;
//今居る所が何色か探し、今居る所のデータを生成し記録してゆく
LinkedListNode<MyCell> before = list.First;//行コピペがおかしい
while(true)
{
var next = before.Next;
if(next == null || next.Value.番地 < Now)
break;
else
before = next;
}
before = list.AddAfter(before, new MyCell { color = before.Value.color, 番地 = Now });//*n*
while(true)
{
//今居る所が黒だったら、黒である保証が無くなる場所を探し、そにに進む
if(before.Value.color == 1)
{
before = before.Next;//ok
Now = before.Value.番地;
}
//今居る所が白だったら、カウンターを減らしながら進むことになる 進むの1手順を、白を黒に変え、次に移動すると定義
if(before.Value.color == 0)
{
//白である保証が無くなる場所を探す もしなかったら無限遠とする
var nextkamo = before.Next;
if(nextkamo != null)
{
//辿りつけなかったら、辿りつけたところまで進み、終わる
if(Count < (nextkamo.Value.番地 - before.Value.番地))
{
//移動した所を黒とする beforeの番地を伸ばす
before.Value.番地 += Count;//structって内部変数変えられないんだ Count=0でもOK
Now = Now + Count;
Count = 0;
break;
}
//辿りつけたら、そこまで進む //そこに進む
else
{
Now = nextkamo.Value.番地;
Count -= (nextkamo.Value.番地 - before.Value.番地);
//移動した範囲を黒とする beforeを消す
before.Previous.Value.color = 1;//*n:
list.Remove(before);
before = nextkamo;
}
}
//辿りつけなかったら、辿りつけたところまで進み、終わる
else
{
//移動した所を黒とする beforeの番地を伸ばす
before.Value.番地 += Count;//structって内部変数変えられないんだ Count=0でもOK
Now = Now + Count;
Count = 0;
break;
}
}
//そして最初に戻る
}//次の実装予定書いてない;
Answer[i] = Now + 1;
}
foreach(var item in Answer)
{
Console.WriteLine(item);
}
Console.ReadKey();//
}
}
class Tempo
{//todo readarray readvalue with exception
static public string ReadString()
{
var i = Console.In;
var sb = new StringBuilder();
while(!Separator(i.Peek()))
{
sb.Append((char)i.Read());//char!!
}
while(Separator(i.Peek()))
{
i.Read();
}
return sb.ToString();
}
static public bool Separator(int c)//else何
{
if(c == ' ' || c == '\n' || c == 'r')
return true;
return false;
}
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Squares, Pieces and Coloring |
| User | toikage |
| Language | C# (Mono 3.2.1.0) |
| Score | 0 |
| Code Size | 3848 Byte |
| Status | WA |
| Exec Time | 2038 ms |
| Memory | 16516 KiB |
Judge Result
| Set Name | Sample | Dataset1 | Dataset2 | Dataset3 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 35 | 0 / 40 | 0 / 25 | ||||||||||||||||||
| Status |
|
|
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| Dataset1 | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt |
| Dataset2 | sample-01.txt, sample-02.txt, sample-03.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt |
| Dataset3 | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 03-01.txt, 03-02.txt, 03-03.txt, 03-04.txt, 03-05.txt, 03-06.txt, 03-07.txt, 03-08.txt, 03-09.txt, 03-10.txt, 03-11.txt, 03-12.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | TLE | 2036 ms | 16108 KiB |
| 01-02.txt | TLE | 2035 ms | 16516 KiB |
| 01-03.txt | TLE | 2037 ms | 16384 KiB |
| 01-04.txt | TLE | 2036 ms | 16108 KiB |
| 01-05.txt | AC | 149 ms | 10792 KiB |
| 01-06.txt | WA | 155 ms | 10988 KiB |
| 01-07.txt | WA | 173 ms | 11232 KiB |
| 01-08.txt | WA | 1756 ms | 15712 KiB |
| 01-09.txt | TLE | 2036 ms | 16224 KiB |
| 02-01.txt | WA | 178 ms | 11344 KiB |
| 02-02.txt | WA | 169 ms | 11360 KiB |
| 02-03.txt | WA | 170 ms | 11492 KiB |
| 02-04.txt | WA | 168 ms | 11348 KiB |
| 02-05.txt | WA | 179 ms | 11360 KiB |
| 02-06.txt | WA | 174 ms | 11364 KiB |
| 02-07.txt | WA | 176 ms | 11292 KiB |
| 02-08.txt | WA | 180 ms | 11328 KiB |
| 02-09.txt | WA | 184 ms | 11372 KiB |
| 02-10.txt | AC | 155 ms | 10872 KiB |
| 02-11.txt | WA | 158 ms | 10864 KiB |
| 02-12.txt | WA | 174 ms | 11428 KiB |
| 03-01.txt | TLE | 2036 ms | 16468 KiB |
| 03-02.txt | TLE | 2038 ms | 16472 KiB |
| 03-03.txt | TLE | 2037 ms | 16384 KiB |
| 03-04.txt | TLE | 2034 ms | 16424 KiB |
| 03-05.txt | TLE | 2038 ms | 16328 KiB |
| 03-06.txt | TLE | 2035 ms | 16380 KiB |
| 03-07.txt | TLE | 2037 ms | 16504 KiB |
| 03-08.txt | TLE | 2037 ms | 16488 KiB |
| 03-09.txt | TLE | 2037 ms | 16452 KiB |
| 03-10.txt | WA | 1148 ms | 15604 KiB |
| 03-11.txt | TLE | 2036 ms | 16140 KiB |
| 03-12.txt | TLE | 2036 ms | 16140 KiB |
| sample-01.txt | WA | 154 ms | 10832 KiB |
| sample-02.txt | WA | 151 ms | 10860 KiB |
| sample-03.txt | WA | 153 ms | 10872 KiB |