本文整理汇总了C#中CFTraining.Helpers.FastScanner.ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# FastScanner.ReadLine方法的具体用法?C# FastScanner.ReadLine怎么用?C# FastScanner.ReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFTraining.Helpers.FastScanner
的用法示例。
在下文中一共展示了FastScanner.ReadLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
try
{
int F = fs.NextInt(), I = fs.NextInt(), T = fs.NextInt();
int[] likes = new int[I];
if (F <= 10 && F >= 1 && I <= 10 && I >= 1 && T <= F && T >= 1)
{
for (int i = 0; i < F; i++)
{
string str = fs.ReadLine();
if (str.Length != I)
{
writer.WriteLine(0);
return;
}
for (int j = 0; j < I; j++)
{
if (str[j] == 'Y') likes[j]++;
else if (str[j] != 'Y' && str[j] != 'N')
{
writer.WriteLine(0);
return;
}
}
}
if (!String.IsNullOrEmpty(fs.ReadLine()))
{
writer.WriteLine(0);
return;
}
int ans = 0;
for (int i = 0; i < I; i++)
{
if (likes[i] >= T) ans++;
}
writer.WriteLine(ans);
}
else writer.WriteLine(0);
}
catch (Exception e)
{
writer.WriteLine(0);
return;
}
}
}
示例2: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
n = fs.NextInt();
m = fs.NextInt();
char[,] a = new char[n, m];
int[][,] dist = new int[4][,];
for (int i = 0; i < 4; i++)
{
dist[i] = new int[n, m];
}
for (int i = 0; i < n; i++)
{
string line = fs.ReadLine();
for (int j = 0; j < m; j++)
{
a[i, j] = line[j];
for (int k = 0; k < 4; k++)
{
dist[k][i, j] = int.MaxValue;
}
}
}
int xt = fs.NextInt() - 1, yt = fs.NextInt() - 1;
int xm = fs.NextInt() - 1, ym = fs.NextInt() - 1;
RunBFS(a, dist, xt, yt);
int ans = Math.Min(dist[0][xm, ym], Math.Min(dist[1][xm, ym], Math.Min(dist[2][xm, ym], dist[3][xm, ym])));
writer.WriteLine(ans == int.MaxValue ? -1 : ans);
}
}
示例3: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
int n = fs.NextInt();
int[] rows = new int[n], cols = new int[n];
for (int i = 0; i < n; i++)
{
string s = fs.ReadLine();
for (int j = 0; j < n; j++)
{
if (s[j] == 'C')
{
rows[i]++;
cols[j]++;
}
}
}
long ans = 0;
for (int i = 0; i < n; i++)
{
ans += (rows[i] * (rows[i] - 1)) / 2;
ans += (cols[i] * (cols[i] - 1)) / 2;
}
writer.WriteLine(ans);
}
}
示例4: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
map = new Dictionary<char, int>();
int val = 0;
for (char c = '0'; c <= '9'; c++) map.Add(c, val++);
for (char c = 'A'; c <= 'Z'; c++) map.Add(c, val++);
for (char c = 'a'; c <= 'z'; c++) map.Add(c, val++);
map.Add('-', val++);
map.Add('_', val++);
string s = fs.ReadLine();
long ans = 1;
foreach (char c in s)
{
string bin = Convert.ToString(map[c], 2);
for (int i = bin.Length + 1; i <= 6; i++)
{
ans = (ans * 3) % 1000000007;
}
foreach (char b in bin)
{
if (b == '0') ans = (ans * 3) % 1000000007;
}
}
writer.WriteLine(ans);
}
}
示例5: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
int n = fs.NextInt(), m = fs.NextInt();
Player[] p = new Player[n];
string[] ans = Enumerable.Repeat("", m).ToArray();
for (int i = 0; i < n; i++)
{
string[] s = fs.ReadLine().Split();
p[i] = new Player { Name = s[0], Region = Convert.ToInt32(s[1]) - 1, Score = Convert.ToInt32(s[2]) };
}
p = p.OrderBy(x => x.Region).ThenByDescending(x => x.Score).ToArray();
int j = 0, lastRegion = -1;
for (int i = 0; i < n; i++)
{
if (p[i].Region != lastRegion)
{
j = 0;
lastRegion = p[i].Region;
}
if (j == 0) ans[p[i].Region] += p[i].Name + " ";
else if (j == 1) ans[p[i].Region] += p[i].Name;
else if (j == 2 && p[i].Score == p[i - 1].Score) ans[p[i].Region] = "?";
j++;
}
for (int i = 0; i < m; i++)
{
writer.WriteLine(ans[i]);
}
}
}
示例6: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
int n = fs.NextInt();
int[] a = new int[n];
List<int[]> d = new List<int[]>();
string s = fs.ReadLine();
for (int i = 0; i < n; i++)
{
a[i] = int.Parse("" + s[i]);
if (i > 0) d.Add(GetDiff(a[i - 1], a[i]));
}
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 3; j++)
{
if (digits[i, j] == a[0]) continue;
if (digits[i, j] != -1 && IsValid(i, j, d))
{
writer.WriteLine("NO");
return;
}
}
}
writer.WriteLine("YES");
}
}
示例7: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
int n = fs.NextInt();
int[] male = new int[367], fem = new int[367];
for (int i = 0; i < n; i++)
{
string[] line = fs.ReadLine().Split(' ');
if (line[0] == "M")
{
int l = Convert.ToInt32(line[1]), r = Convert.ToInt32(line[2]);
for (int j = l; j <= r; j++) male[j]++;
}
else if (line[0] == "F")
{
int l = Convert.ToInt32(line[1]), r = Convert.ToInt32(line[2]);
for (int j = l; j <= r; j++) fem[j]++;
}
}
int ans = 0;
for (int i = 1; i < 367; i++)
{
ans = Math.Max(ans, Math.Min(male[i], fem[i]) * 2);
}
writer.WriteLine(ans);
}
}
示例8: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
string[] exp = fs.ReadLine().Split('e');
string[] num = exp[0].Split('.');
int b = int.Parse(exp[1]);
StringBuilder sb = new StringBuilder(200);
sb.Append(num[0]);
int i = 0;
for (i = 0; i < b; i++)
{
if (i >= num[1].Length) sb.Append("0");
else sb.Append(num[1][i]);
}
if (b < num[1].Length && num[1] != "0")
{
sb.Append(".");
for (; i < num[1].Length; i++)
{
sb.Append(num[1][i]);
}
}
writer.WriteLine(sb);
}
}
示例9: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
int n = fs.NextInt();
long x = fs.NextInt();
int sad = 0;
for (int i = 0; i < n; i++)
{
string[] line = fs.ReadLine().Split();
if (line[0] == "+")
{
x += Convert.ToInt32(line[1]);
}
else
{
int d = Convert.ToInt32(line[1]);
if (x < d) sad++;
else x -= d;
}
}
writer.WriteLine(x + " " + sad);
}
}
示例10: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
int n = fs.NextInt(), k = fs.NextInt();
long[] c = Array.ConvertAll(fs.ReadLine().Split(), Convert.ToInt64);
bool[] isCap = new bool[n];
long sum = c.Sum(), res = 0, caps = 0;
for (int i = 0; i < k; i++)
{
int ind = fs.NextInt() - 1;
isCap[ind] = true;
caps += c[ind];
}
for (int i = 0; i < n; i++)
{
int l = i - 1, r = (i + 1) % n;
if (l < 0) l = n - 1;
if (isCap[i]) res += c[i] * (sum - c[i]);
else
{
res += c[i] * caps;
if (!isCap[l]) res += c[i] * c[l];
if (!isCap[r]) res += c[i] * c[r];
}
}
writer.WriteLine(res / 2);
}
}
示例11: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
int t = fs.NextInt();
Dictionary<string, int> count = new Dictionary<string, int>();
while (t-- > 0)
{
string[] cmd = fs.ReadLine().Split();
if (cmd[0] == "+")
{
long a = Convert.ToInt64(cmd[1]);
string pattern = NumToPattern(a);
if (!count.ContainsKey(pattern)) count.Add(pattern, 0);
count[pattern]++;
}
else if (cmd[0] == "-")
{
long a = Convert.ToInt64(cmd[1]);
string pattern = NumToPattern(a);
count[pattern]--;
}
else
{
string pattern = AppendZeros(cmd[1]);
writer.WriteLine(count.ContainsKey(pattern) ? count[pattern] : 0);
}
}
}
}
示例12: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
string str = fs.ReadLine();
List<int> list = new List<int>(str.Length);
int first = -1;
for (int i = 0; i < str.Length; i++)
{
if (str[i] == 'F')
{
if (first == -1 && list.Count != i)
{
first = list.Count;
}
list.Add(i);
}
}
if (list.Count == 0 || list.Count == str.Length || first == -1)
{
writer.WriteLine(0);
return;
}
int t = 0;
for (int i = first + 1; i < list.Count; i++)
{
t = Math.Max(0, t - list[i] + list[i - 1] + 2);
}
writer.WriteLine(t + list.Last() - list.Count + 1);
}
}
示例13: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
int n = fs.NextInt();
int[] c = Array.ConvertAll(fs.ReadLine().Split(), Convert.ToInt32);
string[] s = new string[n];
for (int i = 0; i < n; i++)
{
s[i] = fs.ReadLine();
}
int vk = 2 * n + 2;
LinkedList<Edge>[] adjList = new LinkedList<Edge>[vk];
for (int i = 0; i < vk; i++)
{
adjList[i] = new LinkedList<Edge>();
}
adjList[0].AddLast(new Edge { To = 1, W = 0 });
adjList[0].AddLast(new Edge { To = n + 1, W = c[0] });
for (int i = 0; i < n - 1; i++)
{
string rev1 = Reverse(s[i]), rev2 = Reverse(s[i + 1]);
if (IsLess(s[i], s[i + 1]))
{
adjList[i + 1].AddLast(new Edge { To = i + 2, W = 0 });
}
if (IsLess(s[i], rev2))
{
adjList[i + 1].AddLast(new Edge { To = n + i + 2, W = c[i + 1] });
}
if (IsLess(rev1, s[i + 1]))
{
adjList[n + i + 1].AddLast(new Edge { To = i + 2, W = 0 });
}
if (IsLess(rev1, rev2))
{
adjList[n + i + 1].AddLast(new Edge { To = n + i + 2, W = c[i + 1] });
}
}
adjList[n].AddLast(new Edge { To = vk - 1, W = 0 });
adjList[vk - 2].AddLast(new Edge { To = vk - 1, W = 0 });
long[] dist = Enumerable.Repeat(long.MaxValue, vk).ToArray();
RunDijkstra(adjList, dist);
writer.WriteLine(dist[vk - 1] != long.MaxValue ? dist[vk - 1] : -1);
}
}
示例14: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
int n = fs.NextInt();
MinHeap<int, int> heap = new MinHeap<int, int>();
List<string> list = new List<string>(2 * n);
for (int i = 0; i < n; i++)
{
string line = fs.ReadLine();
string[] tokens = line.Split();
string cmd = tokens[0];
if (cmd == "insert") {
int x = Convert.ToInt32(tokens[1]);
heap.Insert(x, x);
}
else if (cmd == "getMin") {
int x = Convert.ToInt32(tokens[1]);
if (heap.Count > 0)
{
int min = heap.GetMin().Value;
while (min < x)
{
heap.ExtractMin();
list.Add("removeMin");
if (heap.Count == 0) break;
else min = heap.GetMin().Value;
}
if (heap.Count == 0 || min > x)
{
heap.Insert(x, x);
list.Add("insert " + x);
}
}
else
{
heap.Insert(x, x);
list.Add("insert " + x);
}
}
else {
if (heap.Count > 0) heap.ExtractMin();
else list.Add("insert 1");
}
list.Add(line);
}
writer.WriteLine(list.Count);
foreach (string line in list)
{
writer.WriteLine(line);
}
}
}
示例15: Run
public static void Run()
{
using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
{
int n = fs.NextInt(), k = fs.NextInt();
string s = fs.ReadLine();
int max = Solve(s, n, k, 'a');
max = Math.Max(Solve(s, n, k, 'b'), max);
writer.WriteLine(max);
}
}