Account
Draft saved on this device
▤ DescriptionOriginal CppValley problem
Design PatternsEasy

Implement A Simple Factory For Shape Objects

A shape factory creates either SQUARE with one side length or RECT with width and height.

A shape factory creates either SQUARE with one side length or RECT with width and height. Calculate each created shape's integer area and print it, preserving input order. All dimensions are nonnegative integers.

Input format

First line N; next N lines SQUARE side or RECT width height.

Output format

Print one 64-bit integer area per shape.

Examples

Example 1
Input
3
SQUARE 3
RECT 4 5
SQUARE 0
Expected output
9
20
0

Constraints

  • 0 ≤ N ≤ 100000
  • 0 ≤ dimensions ≤ 10^9

Related concepts

Factory Pattern

This early-access exercise uses standard input/output. More advanced concurrency challenges will use specialized class interfaces, instrumentation, and stress tests once the judging infrastructure is ready.

⌘ CodeC++17
GNU C++17 · main.cpp

Loading Monaco C++ editor…

Checking judge...

Checking whether the external C++ judge is available.

⌁ Test cases & resultsPublic samples: 1
Input
3
SQUARE 3
RECT 4 5
SQUARE 0
Expected output
9
20
0
Execution requires a secure external judge.